You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to check for the presence of the required global attributes from the table (i.e., run cmor_has_required_global_attributes) after cmor.dataset / cmor_set_cur_dataset_attribute (perhaps when running cmor.load_table, assuming cmor.dataset has been previously run?) rather than waiting until cmor.write (as shown in the example below), so that any errors can be caught sooner?
The output when I run cmor_example.py (see below) is:
No module named cdms2
Running cmor.setup
Running cmor.dataset
Running cmor.load_table
Running cmor.axis
Running cmor.variable
Running cmor.write
C Traceback:
In function: cmor_has_required_global_attributes
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !
! Error: Required global attribute parent_experiment_rip is missing please check call(s) to cmor_dataset and/or cmor_set_cur_dataset_attribute !
! !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Note that the example, which is based on 'Sample Program 1' from the CMOR Users Guide, doesn't work as-is, since parent_experiment_rip is not defined in cmor.dataset (but exists in the required_global_attributes in the table).
Contents of cmor_example.py:
#! /usr/bin/env pythonimportcmordefmain():
""" 'Sample Program 1' from the CMOR Users Guide. ``CMIP5_Amon`` table from https://github.com/PCMDI/ cmip5-cmor-tables/blob/master/Tables/CMIP5_Amon. Some minor edits were made: * ``inpath`` was removed from ``cmor.setup``. * ``source``, ``model_id`` and ``forcing`` in ``cmor.dataset`` were updated. This sample program doesn't work as the ``CMIP5_Amon`` table has ``parent_experiment_rip`` in the ``required_global_attributes``. """print'Running cmor.setup'cmor.setup(netcdf_file_action=cmor.CMOR_REPLACE)
print'Running cmor.dataset'cmor.dataset(
experiment_id='historical', institution='ukmo', source='HadCM3 (2010)',
calendar='360_day', contact='Tim Lincecum, timmy@sfgiants.com',
model_id='HadCM3', forcing='N/A', institute_id='pcmdi',
parent_experiment_id='N/A', branch_time=0.)
print'Running cmor.load_table'table='CMIP5_Amon'cmor.load_table(table)
print'Running cmor.axis'itime=cmor.axis(table_entry='time',
units='days since 2000-01-01 00:00:00', coord_vals=[15,],
cell_bounds=[0, 30])
ilat=cmor.axis(table_entry='latitude', units='degrees_north',
coord_vals=[0], cell_bounds=[-1, 1])
ilon=cmor.axis(table_entry='longitude', units='degrees_east',
coord_vals=[90], cell_bounds=[89, 91])
axis_ids= [itime, ilat, ilon]
print'Running cmor.variable'varid=cmor.variable('ts', 'K', axis_ids)
print'Running cmor.write'cmor.write(varid, [273])
print'Running cmor.close'path=cmor.close(varid, file_name=True)
printpathcmor.close()
if__name__=='__main__':
main()
The text was updated successfully, but these errors were encountered:
@ehogan I don't think we can because some project have required attributes that will not be set by cmor.dataset and require to be set via set_cur_dataset. So we have to wait until we actually try to write to the file to be sure all defintiions are done. does that make sense? Feel free to re-open
Would it be possible to check for the presence of the required global attributes from the table (i.e., run
cmor_has_required_global_attributes
) aftercmor.dataset
/cmor_set_cur_dataset_attribute
(perhaps when runningcmor.load_table
, assumingcmor.dataset
has been previously run?) rather than waiting untilcmor.write
(as shown in the example below), so that any errors can be caught sooner?The output when I run
cmor_example.py
(see below) is:Note that the example, which is based on 'Sample Program 1' from the CMOR Users Guide, doesn't work as-is, since
parent_experiment_rip
is not defined incmor.dataset
(but exists in therequired_global_attributes
in the table).Contents of
cmor_example.py
:The text was updated successfully, but these errors were encountered: