rigoudyg / climaf

CliMAF - a Climate Model Analysis Framework - doc at : http://climaf.readthedocs.org/
Other
18 stars 7 forks source link

Define the equality of 2 datasets ? #208

Closed jypeter closed 2 years ago

jypeter commented 3 years ago

This is probably not a priority, but it could be useful to be able test if 2 datasets are equal

In the example below, I seem to have to equal datasets (at least their crs and kvp values are equal), but they don't evaluate as equal

pmip_exp_resolved = pmip_exp_query.explore('resolve')

>>> pmip_exp_query == pmip_exp_resolved
False

>>> pmip_exp_query.kvp
{'project': 'CMIP6', 'simulation': '', 'variable': 'pr', 'period': 2300-2399, 'domain': 'global', 'root': '/bdd', 'model': 'IPSL-CM6A-LR', 'institute': 'IPSL', 'mip': 'PMIP', 'table': 'Amon', 'experiment': 'midHolocene', 'realization': 'r1i1p1f1', 'grid': 'gr', 'version': 'latest'}

>>> pmip_exp_resolved.kvp
{'project': 'CMIP6', 'simulation': '', 'variable': 'pr', 'period': 2300-2399, 'domain': 'global', 'root': '/bdd', 'model': 'IPSL-CM6A-LR', 'institute': 'IPSL', 'mip': 'PMIP', 'table': 'Amon', 'experiment': 'midHolocene', 'realization': 'r1i1p1f1', 'grid': 'gr', 'version': 'latest'}

>>> pmip_exp_query.kvp == pmip_exp_resolved.kvp
True

>>> pmip_exp_query.crs
"ds('CMIP6%%pr%2300-2399%global%/bdd%IPSL-CM6A-LR%IPSL%PMIP%Amon%midHolocene%r1i1p1f1%gr%latest')"
>>> pmip_exp_resolved.crs

"ds('CMIP6%%pr%2300-2399%global%/bdd%IPSL-CM6A-LR%IPSL%PMIP%Amon%midHolocene%r1i1p1f1%gr%latest')"

>>> pmip_exp_query.crs == pmip_exp_resolved.crs
True

>>> dir(pmip_exp_query)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'alias', 'baseFiles', 'buildcrs', 'check', 'crs', 'domain', 'domainIsFine', 'erase', 'errata', 'explore', 'files', 'frequency', 'hasExactVariable', 'hasOneMember', 'hasRawVariable', 'isCached', 'isLocal', 'kvp', 'listfiles', 'local_copies_of_remote_files', 'matches_conditions', 'missingIsOK', 'model', 'oneVarPerFile', 'period', 'periodHasOneFile', 'periodIsFine', 'project', 'register', 'setperiod', 'simulation', 'variable']
rigoudyg commented 3 years ago

@jypeter Thank you for your suggestion. I have added equality check for cdataset in PR #211. Can you check that it is what you expect?

jypeter commented 3 years ago

Thanks @rigoudyg for checking this! I have to confess I only use git(hub) for creating issues, and not for actually getting and testing new (or temporary) versions of the code. I just use an existing module on ciclad (currently module load climaf/2.0.0-python3.6)

I have quickly checked with @jservonnat how I could proceed to get my own temporary version to test updated stuff, but first (and this may take some time) I have to try to create some plots with the data I have generated at last with CliMAF, and also check if I have used CliMAF properly