Skip to content

Commit

Permalink
Merge pull request #41 from PCMDI/issue_40_climo_bnds_non_monotonic_j…
Browse files Browse the repository at this point in the history
…ust_warn

fix #40
  • Loading branch information
doutriaux1 committed Sep 3, 2015
2 parents 904951e + 9d72e47 commit 96e3489
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Src/cmor_axes.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ int cmor_check_monotonic(double *values,int length, char *name,int isbounds, int
}
else {
snprintf(msg,CMOR_MAX_STRING,"axis %s (table: %s) has non monotonic bounds values : %lf, %lf, %lf",name,cmor_tables[cmor_axes[axis_id].ref_table_id].table_id,values[2*i],values[2*i+2],values[2*i+4]);
cmor_handle_error(msg,CMOR_CRITICAL);
if (refaxis->climatology==0) {
cmor_handle_error(msg,CMOR_CRITICAL);
} else {
cmor_handle_error(msg,CMOR_WARNING);
}
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions Test/test_non_monotonic_climo_bonds_ok.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import cmor

## Hypothetical data are going from march 2000 thru feb 2010
times = [72,75,78]
times_bnds = [[11,134],[2,125],[5,128]] # first full djf one year later than first full mam


def path_test():
cmor.setup(inpath='TestTables',netcdf_file_action=cmor.CMOR_REPLACE)

cmor.dataset('historical', 'ukmo', 'HadCM3', '360_day',model_id='HadCM3',forcing='Nat',
contact="J.T. Snow",
institute_id="PCMDI",
parent_experiment_id="N/A",
parent_experiment_rip="N/A",
branch_time=0)

table='CMIP5_Amon'
cmor.load_table(table)
axes = [ {'table_entry': 'time2',
'units': 'months since 2000-01-01 00:00:00',
'coord_vals': times,
'cell_bounds': times_bnds,
},
{'table_entry': 'plevs',
'units': 'Pa',
'coord_vals': [100000., 92500., 85000., 70000., 60000., 50000.,
40000., 30000., 25000., 20000., 15000.,
10000., 7000., 5000., 3000., 2000., 1000.]},
{'table_entry': 'latitude',
'units': 'degrees_north',
'coord_vals': [0],
'cell_bounds': [-1, 1]},
{'table_entry': 'longitude',
'units': 'degrees_east',
'coord_vals': [90],
'cell_bounds': [89, 91]},
]

axis_ids = list()
for axis in axes:
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
varid = cmor.variable('co2Clim', '1.e-6', axis_ids)
import numpy
data =numpy.array([3,4,5])
data.resize((3,17,1,1))
cmor.write(varid, data)
path=cmor.close(varid, file_name=True)

print path

if __name__ == '__main__':
path_test()

0 comments on commit 96e3489

Please sign in to comment.