Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test [DO NOT MERGE] #753

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
af44acb
Access NetCDF zstandard compression and quantization functions
mauzey1 Jun 5, 2024
5620960
Add Python functions for set_zstandard and set_quantize
mauzey1 Jun 11, 2024
0ac855b
Only apply quantization and zstandard compression to the data
mauzey1 Jun 26, 2024
81b97c6
Merge branch 'main' into 725_expose_netcdf_quantize_and_zstandard
mauzey1 Jun 26, 2024
14ed749
Merge branch 'main' into 725_expose_netcdf_quantize_and_zstandard
mauzey1 Jul 15, 2024
3f40a05
Have zstandard compression only be applied if deflate is disabled, an…
mauzey1 Jul 29, 2024
c8a5289
Add zstandard compression test
mauzey1 Jul 29, 2024
f1550d7
Add quantization test
mauzey1 Jul 30, 2024
9dfbb96
Add zstandard and quantize functions to Fortran interface
mauzey1 Jul 30, 2024
f0d7c59
Check if zstandard and quantize functions are supported in the NetCDF…
mauzey1 Aug 8, 2024
739c4b0
Apply zstandard and quantize to dimensions, grids, and zfactors
mauzey1 Aug 8, 2024
17a784f
Just test python 3.10
mauzey1 Aug 8, 2024
f1a335f
Remove zstandard and quantize from variables other than data
mauzey1 Aug 8, 2024
07034bf
Remove zstandard and quantize function checks
mauzey1 Aug 9, 2024
4114845
Remove quantize and zstandard functions from cmor.c
mauzey1 Aug 9, 2024
256375b
Remove setting of zstandard and quantize values in variables
mauzey1 Aug 9, 2024
3463ac0
Remove setting of zstandard and quantize values in cmor_variables.c
mauzey1 Aug 12, 2024
c6ad126
Remove zstandard and quantize values from variable structs
mauzey1 Aug 12, 2024
2ac1b13
Add zstandard and quantize back to cmor_variable_def_
mauzey1 Aug 12, 2024
b126cd6
Add zstandard and quantize back to cmor_var_
mauzey1 Aug 12, 2024
7785b0b
Remove zstandard and quantize from cmor_variable_def_ again
mauzey1 Aug 12, 2024
6bacd6f
Disable singleton test
mauzey1 Aug 12, 2024
d14fb94
Check values of singleton id check
mauzey1 Aug 14, 2024
381a43d
Enable singleton test
mauzey1 Aug 14, 2024
62d9c3f
Check all axis ids
mauzey1 Aug 14, 2024
6e7e8b6
Uses num_axes instead of ndims
mauzey1 Aug 14, 2024
46656e9
Remove quantize value
mauzey1 Aug 14, 2024
784dd68
Remove zstandard value
mauzey1 Aug 14, 2024
22b004f
move zstandard and quantize values to be above ndims and singleton_id…
mauzey1 Aug 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ workflows:
matrix:
parameters:
os: [ linux ]
python_version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python_version: [ "3.10" ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any future compatibility issue created by pinning to a single version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR was meant for testing only. I do not plan to merge it. I reduced the number of Python versions so that only a small number of CI processes are launched.

name: build-<< matrix.os >>-<< matrix.python_version >>

- upload:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
C_COMPILER: clang_osx-64
FORTRAN_COMPILER: gfortran_osx-64
PROJECT_DIR: workdir/macos_64
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.10']
runs-on: ${{ matrix.runner.RUNNER_OS }}
env:
PACKAGE_NAME: cmor
Expand Down
5 changes: 3 additions & 2 deletions Lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
close, grid, set_grid_mapping, time_varying_grid_coordinate, dataset_json,
set_cur_dataset_attribute, get_cur_dataset_attribute,
has_cur_dataset_attribute, set_variable_attribute, get_variable_attribute,
has_variable_attribute, get_final_filename, set_deflate, set_furtherinfourl,
set_climatology, get_climatology, set_terminate_signal, get_terminate_signal)
has_variable_attribute, get_final_filename, set_deflate, set_zstandard,
set_quantize, set_furtherinfourl, set_climatology, get_climatology,
set_terminate_signal, get_terminate_signal)

try:
from check_CMOR_compliant import checkCMOR
Expand Down
35 changes: 35 additions & 0 deletions Lib/pywrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,41 @@ def set_deflate(var_id, shuffle, deflate, deflate_level):
return _cmor.set_deflate(var_id, shuffle, deflate, deflate_level)


def set_zstandard(var_id, zstandar_level):
"""Sets Zstandard compression on a cmor variable
Usage:
cmor.set_zstandard(var_id, szstandar_level)
Where:
var_id: is cmor variable id
zstandar_level: Compression level. Must be set from -131072 to 22

"""

return _cmor.set_zstandard(var_id, zstandar_level)


def set_quantize(var_id, quantize_mode, quantize_nsd):
"""Sets quantization on a cmor variable
Usage:
cmor.set_quantize(var_id, quantize_mode, quantize_nsd)
Where:
var_id: is cmor variable id
quantize_mode: Quantization mode. Can be set to the following.
0: No quantization mode
1: BitGroom
2: Granular BitRound
3: BitRound
quantize_nsd: Number of significant digits. If quantize_mode is set to
1 or 2, then the value can be set from 1 to 7 for floats
and 1 to 23 for doubles. If quantize_mode is set to 3, then
the value can be set from 1 to 15 for floats and 1 to 52
for doubles. The value is ignore if quantize_mode is 0.

"""

return _cmor.set_quantize(var_id, quantize_mode, quantize_nsd)


def has_variable_attribute(var_id, name):
"""determines if the a cmor variable has an attribute
Usage:
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ test_python: python
env TEST_NAME=Test/test_cmor_python_not_enough_times_written.py make test_a_python
env TEST_NAME=Test/test_python_forecast_coordinates.py make test_a_python
env TEST_NAME=Test/test_cmor_CMIP6Plus.py make test_a_python
env TEST_NAME=Test/test_cmor_zstandard_and_quantize.py make test_a_python
test_cmip6_cv: python
env TEST_NAME=Test/test_python_CMIP6_CV_sub_experimentnotset.py make test_a_python
env TEST_NAME=Test/test_python_CMIP6_CV_sub_experimentbad.py make test_a_python
Expand Down
48 changes: 48 additions & 0 deletions Src/_cmormodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,52 @@ static PyObject *PyCMOR_set_deflate(PyObject * self, PyObject * args)
return (Py_BuildValue("i", ierr));
}

/************************************************************************/
/* PyCMOR_set_zstandard() */
/************************************************************************/
static PyObject *PyCMOR_set_zstandard(PyObject * self, PyObject * args)
{
signal(signal_to_catch, signal_handler);
int ierr, var_id, zstandard_level;

if (!PyArg_ParseTuple
(args, "ii", &var_id, &zstandard_level))
return NULL;

ierr = cmor_set_zstandard(var_id, zstandard_level);

if (ierr != 0 || raise_exception) {
raise_exception = 0;
PyErr_Format(CMORError, exception_message, "set_zstandard");
return NULL;
}

return (Py_BuildValue("i", ierr));
}

/************************************************************************/
/* PyCMOR_set_quantize() */
/************************************************************************/
static PyObject *PyCMOR_set_quantize(PyObject * self, PyObject * args)
{
signal(signal_to_catch, signal_handler);
int ierr, var_id, quantize_mode, quantize_nsd;

if (!PyArg_ParseTuple
(args, "iii", &var_id, &quantize_mode, &quantize_nsd))
return NULL;

ierr = cmor_set_quantize(var_id, quantize_mode, quantize_nsd);

if (ierr != 0 || raise_exception) {
raise_exception = 0;
PyErr_Format(CMORError, exception_message, "set_quantize");
return NULL;
}

return (Py_BuildValue("i", ierr));
}

/************************************************************************/
/* PyCMOR_set_variable_attribute() */
/************************************************************************/
Expand Down Expand Up @@ -1146,6 +1192,8 @@ static PyMethodDef MyExtractMethods[] = {
{"set_furtherinfourl", PyCMOR_set_furtherinfourl, METH_VARARGS},
{"get_final_filename", PyCMOR_getFinalFilename, METH_VARARGS},
{"set_deflate", PyCMOR_set_deflate, METH_VARARGS},
{"set_zstandard", PyCMOR_set_zstandard, METH_VARARGS},
{"set_quantize", PyCMOR_set_quantize, METH_VARARGS},
{"set_terminate_signal", PyCMOR_set_terminate_signal, METH_VARARGS},
{"get_terminate_signal", PyCMOR_get_terminate_signal, METH_VARARGS},
{NULL, NULL} /*sentinel */
Expand Down
17 changes: 17 additions & 0 deletions Src/cmor_cfortran_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ int cmor_set_deflate_cff_(int *var_id, int *shuffle,
return (cmor_set_deflate(*var_id, *shuffle, *deflate, *deflate_level));
}

/************************************************************************/
/* cmor_set_zstandard_cff_() */
/************************************************************************/
int cmor_set_zstandard_cff_(int *var_id, int *zstandard_level)
{
return (cmor_set_zstandard(*var_id, *zstandard_level));
}

/************************************************************************/
/* cmor_set_quantize_cff_() */
/************************************************************************/
int cmor_set_quantize_cff_(int *var_id, int *quantize_mode,
int *quantize_level)
{
return (cmor_set_quantize(*var_id, *quantize_mode, *quantize_level));
}

/************************************************************************/
/* cmor_get_variable_attribute_cff_() */
/************************************************************************/
Expand Down
37 changes: 37 additions & 0 deletions Src/cmor_fortran_interface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ function cmor_set_deflate_cff(var_id, shuffle, deflate, deflate_level )result (i
end function cmor_set_deflate_cff
end interface

interface
function cmor_set_zstandard_cff(var_id, zstandard_level )result (ierr)

integer, intent(in) :: var_id
integer, intent(in) :: zstandard_level
integer :: ierr
end function cmor_set_zstandard_cff
end interface

interface
function cmor_set_quantize_cff(var_id, quantize_mode, quantize_nsd )result (ierr)

integer, intent(in) :: var_id
integer, intent(in) :: quantize_mode
integer, intent(in) :: quantize_nsd
integer :: ierr
end function cmor_set_quantize_cff
end interface

interface
function cmor_setup_cff_nolog(path,ncmode,verbosity,mode,crsub) result (j)
integer ncmode,verbosity,mode, j, crsub
Expand Down Expand Up @@ -7168,6 +7187,24 @@ function cmor_set_deflate(var_id, shuffle, deflate, deflate_level) result (ierr)
integer ierr
ierr = cmor_set_deflate_cff(var_id, shuffle, deflate, deflate_level)
end function cmor_set_deflate

function cmor_set_zstandard(var_id, zstandard_level) result (ierr)
implicit none
integer, intent (in) :: var_id
integer, intent (in) :: zstandard_level
integer ierr
ierr = cmor_set_zstandard_cff(var_id, zstandard_level)
end function cmor_set_zstandard

function cmor_set_quantize(var_id, quantize_mode, quantize_nsd) result (ierr)
implicit none
integer, intent (in) :: var_id
integer, intent (in) :: quantize_mode
integer, intent (in) :: quantize_nsd
integer ierr
ierr = cmor_set_quantize_cff(var_id, quantize_mode, quantize_nsd)
end function cmor_set_quantize

function cmor_setup_ints(inpath,netcdf_file_action, set_verbosity,&
exit_control, logfile, create_subdirectories) result(ierr)
implicit none
Expand Down
48 changes: 48 additions & 0 deletions Src/cmor_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,54 @@ int cmor_set_deflate(int var_id, int shuffle, int deflate, int deflate_level)
return (0);
}

/************************************************************************/
/* cmor_set_zstandard() */
/************************************************************************/
int cmor_set_zstandard(int var_id, int zstandard_level)
{
char msg[CMOR_MAX_STRING];

cmor_add_traceback("cmor_set_zstandard");
cmor_is_setup();

if (cmor_vars[var_id].self != var_id) {
snprintf(msg, CMOR_MAX_STRING,
"You attempted to set the zstandard level of "
"variable id(%d) which was not initialized", var_id);
cmor_handle_error_var(msg, CMOR_CRITICAL, var_id);
cmor_pop_traceback();

return (-1);
}

cmor_pop_traceback();
return (0);
}

/************************************************************************/
/* cmor_set_quantize() */
/************************************************************************/
int cmor_set_quantize(int var_id, int quantize_mode, int quantize_nsd)
{
char msg[CMOR_MAX_STRING];

cmor_add_traceback("cmor_set_quantize");
cmor_is_setup();

if (cmor_vars[var_id].self != var_id) {
snprintf(msg, CMOR_MAX_STRING,
"You attempted to set the quantize mode of "
"variable id(%d) which was not initialized", var_id);
cmor_handle_error_var(msg, CMOR_CRITICAL, var_id);
cmor_pop_traceback();

return (-1);
}

cmor_pop_traceback();
return (0);
}

/************************************************************************/
/* cmor_get_variable_time_length() */
/************************************************************************/
Expand Down
Loading
Loading