ec-jrc/pyPoseidon

assigning self.obs to a string in shism.py

Closed this issue · 1 comments

I ran into this while implementing observation on TELEMAC:

self.obs which should be a xr.Dataset is assigned a string here

This leads into the assignation for obs to fail sistematically:

        try:
            stations["location"] = self.obs.location.values
            stations["provider_id"] = self.obs.ioc_code.values
            stations["provider"] = "ioc"
            stations["longitude"] = self.obs.longitude.values
            stations["latitude"] = self.obs.latitude.values
        except:
            pass

at line 1821

I would suggest simply to do :

self.obs = tg instead of self.obs = tg_database

or even better: to move this assignation a couple lines later and assign it to the normalised dataset here

self.obs = tg

brey commented

Indeed this is bug. However, it's the other way around. We should replace

        try:
            stations["location"] = tgn.location.values
            stations["provider_id"] = tgn.ioc_code.values
            stations["provider"] = "ioc"
            stations["longitude"] = tgn.longitude.values
            stations["latitude"] = tgn.latitude.values
        except:
            pass

This is because the self.obs is saved in the end within the model.json file. Saving therein thousands of lines of stations (in the global case) makes the file not readable. Saving only the filename of the station.json works much better.

At some point this needs to be generalised. I don't like the hardcoded ioc there.