cosima-recipes icon indicating copy to clipboard operation
cosima-recipes copied to clipboard

Problems running DocumentedExamples/Querying_Scalar_Quantities.ipynb

Open MatthisAuger opened this issue 2 years ago • 3 comments

Hi,

Looks like the Querying_Scalar_Quantities documented example is not running. This example queries the total_ocean_salt variable from multiple experiments to compare the time series. The code gets all 0.25 degree experiments which are based on the JRA55v13 forcing with at least 2000 NetCDF files, which are those one (note that these experiments are not the same as the original notebook):

'025deg_jra55v13_iaf_gmredi6', '025deg_jra55v13_ryf8485_spinup', '025deg_jra55v13_ryf9091_gmredi6'

This notebooks raise several errors here:

if da.time.values[0].year > 1000:

AttributeError: 'numpy.datetime64' object has no attribute 'year'

This error can be corrected by changing to

if pd.DatetimeIndex(da.time.values)[0].year > 1000:

But then the second experiment does not have the same time format as the others and this line leads to:

TypeError: <class 'cftime._cftime.DatetimeNoLeap'> is not convertible to datetime

So the 025deg_jra55v13_ryf8485_spinup variables have a different time format than the others.

da.time.data[0]
cftime.DatetimeNoLeap(1, 1, 16, 12, 0, 0, 0, has_year_zero=True)

How do we convert this into the usual datetime64 format? Should we just skip this experiment for this particular example?

MatthisAuger avatar Jan 24 '23 03:01 MatthisAuger

I would suggest skipping that experiment (025deg_jra55v13_ryf8485_spinup). It is very old.

rmholmes avatar Jan 24 '23 03:01 rmholmes

I will look into it and likely remove it from the database.

rmholmes avatar Jan 24 '23 03:01 rmholmes

A good test experiment to test your notebook's on would be 025deg_jra55_iaf_omip2_cycle6.

rmholmes avatar Jan 24 '23 03:01 rmholmes

This was addressed during hackathon 2.0 (See PR: https://github.com/COSIMA/cosima-recipes/pull/247#issue-1571720334)

MatthisAuger avatar Jul 01 '24 03:07 MatthisAuger