Skip to content

Commit 84fd521

Browse files
committed
Added missing integer parameter for setting up variable. Using table values instead of file values for setting up variable.
1 parent e002cb0 commit 84fd521

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

LibCV/PrePARE/PrePARE.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,9 @@ def ControlVocab(self, ncfile, variable=None, print_all=True):
535535
# Setup variable
536536
# -------------------------------------------------------------------
537537
varid = cmip6_cv.setup_variable(variable_cmor_entry,
538-
self.dictVar['units'],
539-
self.dictVar['_FillValue'],
538+
cmor_table['variable_entry'][variable_cmor_entry]['units'],
539+
float(cmor_table['Header']['missing_value']),
540+
int(cmor_table['Header']['int_missing_value']),
540541
startime,
541542
endtime,
542543
startimebnds,

LibCV/pywrapper.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def check_ISOTime():
375375
return(ierr)
376376

377377

378-
def setup_variable(name, units, missing, startime,
378+
def setup_variable(name, units, missing, imissing, startime,
379379
endtime, startimebnds, endtimebnds):
380380
'''
381381
Create variable attributes from the table loaded by load_table.
@@ -385,7 +385,8 @@ def setup_variable(name, units, missing, startime,
385385
Where:
386386
name is the variable name to validate
387387
units are the variable units
388-
missing is the missing value for this variable.
388+
missing is the missing floating-point value for this variable.
389+
imissing is the missing integer value for this variable.
389390
startime: time value for first part of timestap -- time[0]
390391
endtime: time value for last part of timestap -- time[-1]
391392
startimebnds: time bound value for first part of timestap -- time_bnds[0]
@@ -397,6 +398,7 @@ def setup_variable(name, units, missing, startime,
397398
name,
398399
units,
399400
missing,
401+
imissing,
400402
startime,
401403
endtime,
402404
startimebnds,

Src/_controlvocabulary.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "numpy/arrayobject.h"
55
#include "cmor.h"
66

7-
extern int cmor_CV_variable(int *, char *, char *, double *,
7+
extern int cmor_CV_variable(int *, char *, char *, float *, int *,
88
double, double, double, double);
99

1010
/************************************************************************/
@@ -570,7 +570,7 @@ static PyObject *PyCMOR_getincvalues(PyObject * self, PyObject * args)
570570
}
571571

572572
/************************************************************************/
573-
/* PyCV_check_variable() */
573+
/* PyCV_setup_variable() */
574574
/************************************************************************/
575575
static PyObject *PyCV_setup_variable(PyObject * self, PyObject * args)
576576
{
@@ -585,13 +585,13 @@ static PyObject *PyCV_setup_variable(PyObject * self, PyObject * args)
585585

586586
int var_id;
587587

588-
if (!PyArg_ParseTuple(args, "ssfdddd", &name, &units, &missing,
588+
if (!PyArg_ParseTuple(args, "ssfidddd", &name, &units, &missing, &imissing,
589589
&startime, &endtime, &startimebnds, &endtimebnds)) {
590590
return (Py_BuildValue("i", -1));
591591
}
592592

593-
cmor_CV_variable(&var_id, name, units, &missing, startime, endtime,
594-
startimebnds, endtimebnds);
593+
cmor_CV_variable(&var_id, name, units, &missing, &imissing,
594+
startime, endtime, startimebnds, endtimebnds);
595595

596596
return (Py_BuildValue("i", var_id));
597597

Src/cmor_CV.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,8 @@ int cmor_CV_checkISOTime(char *szAttribute)
22892289
/************************************************************************/
22902290
/* cmor_CV_variable() */
22912291
/************************************************************************/
2292-
int cmor_CV_variable(int *var_id, char *name, char *units, float *missing,
2292+
int cmor_CV_variable(int *var_id, char *name, char *units,
2293+
float *missing, int *imissing,
22932294
double startime, double endtime,
22942295
double startimebnds, double endtimebnds)
22952296
{
@@ -2466,13 +2467,11 @@ int cmor_CV_variable(int *var_id, char *name, char *units, float *missing,
24662467
}
24672468

24682469
if (refvar.type == 'i') {
2469-
int nMissing;
2470-
nMissing = (int) *missing;
24712470
cmor_vars[vrid].type = 'i';
24722471
cmor_set_variable_attribute_internal(vrid, VARIABLE_ATT_MISSINGVALUES,
2473-
'i', &nMissing);
2472+
'i', &imissing);
24742473
cmor_set_variable_attribute_internal(vrid, VARIABLE_ATT_FILLVAL, 'i',
2475-
&nMissing);
2474+
&imissing);
24762475
} else {
24772476
if (refvar.type == '\0') {
24782477
cmor_vars[vrid].type = 'f';

0 commit comments

Comments
 (0)