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
Climada Version: 5.0.1-dev (But presumably also 5.0.0)
My understanding of the problem is that get_hazard() calls Hazard.from_hdf5() (or the appropriate reader) and that the reader methods within Hazard only read Hazard defined attributes and not the ones defined in subclasses.
I already noticed something similar when storing/reading hdf5 files within a pipeline (i.e., that the defined attributes were not the same depending on if you read the files with Hazard.from_hdf5() or TropCyclone.from_hdf5()).
The problem for the client.get_hazard() method can probably be easily fixed by using the reader from the appropriate subclass depending on the "hazard_type" argument given to the method.
But I think it would be possible (and much better), for the Hazard reader to read and return the "intended" object from the file.
That is Hazard.from_hdf5("Dataset_of_tropical_cyclones.hdf5") would return a TropCyclone and not Hazard.
My understanding is that this would require implementing a Factory Pattern, with inspiration from here, for instance.
This would probably be a sizeable overall of the reader (and maybe the writers also), but I think this is something we should have in mind.
The text was updated successfully, but these errors were encountered:
Describe the bug
I noticed that getting TCs (And I suppose any Hazard) from the API removes some of their attributes (at least
basin
).To Reproduce
Steps to reproduce the behaviour/error:
Expected behavior
The TC attributes are correctly read.
Climada Version: 5.0.1-dev (But presumably also 5.0.0)
My understanding of the problem is that
get_hazard()
callsHazard.from_hdf5()
(or the appropriate reader) and that the reader methods within Hazard only read Hazard defined attributes and not the ones defined in subclasses.I already noticed something similar when storing/reading hdf5 files within a pipeline (i.e., that the defined attributes were not the same depending on if you read the files with
Hazard.from_hdf5()
orTropCyclone.from_hdf5()
).The problem for the
client.get_hazard()
method can probably be easily fixed by using the reader from the appropriate subclass depending on the "hazard_type" argument given to the method.But I think it would be possible (and much better), for the Hazard reader to read and return the "intended" object from the file.
That is
Hazard.from_hdf5("Dataset_of_tropical_cyclones.hdf5")
would return aTropCyclone
and notHazard
.My understanding is that this would require implementing a Factory Pattern, with inspiration from here, for instance.
This would probably be a sizeable overall of the reader (and maybe the writers also), but I think this is something we should have in mind.
The text was updated successfully, but these errors were encountered: