CALIPSO-project / SPINacc

A spinup acceleration procedure for land surface models (LSM) . Developer team Mandresy Rasolonjatovo, Tianzhang Cai, Matthew Archer, Daniel Goll
4 stars 0 forks source link

half degree resolution - not accepted by json #12

Closed dsgoll123 closed 3 years ago

dsgoll123 commented 3 years ago

We cannot set 0.5 to 'lat_reso' or 'lat_reso' in json.var without causing a crash when reading the json file.

The variables are used by main.py to compute auxil.nlat. auxil.nlat is again computed independently of lat_reso in Tools/readvar.py.

Q1: Do we need to compute the same variable twice? Q2: Do we need lat_reso and lat_reso? If so, how can we make it handle .5 instead of integers?

YilongWang commented 3 years ago

Hi Daniel,

Could you tell me where the code is and paste the error message so that I can check how it happens. In principle, it should be able to handle 0.5 degree. In the varlist.json, there must be a comma at the end of the each line, otherwise, it will crash.

for Q1: In readvar.py, auxil.lat_reso and auxil.lon_reso are just read from varlist.json. In main.py, they are used to calculate the index of selected pixles auxil.Nlat and auxil.Nlon.

dsgoll123 commented 3 years ago

the code should be as on github. The following change in DEF_MICT/varlist.json triggers the crash: from "coord_ref":"/home/surface3/dgoll/SPINUP_ML/TEST_DATA/MICT/MICT-CRUJRAv2_for_Yan_MLtaskforce/firemip.spin0.nofire_10011231_stomate_rest.nc", "axes_name":["nav_lat","nav_lon"], "lat_reso":1, "lon_reso":1, to "coord_ref":"/home/surface3/dgoll/SPINUP_ML/TEST_DATA/MICT/MICT-CRUJRAv2_for_Yan_MLtaskforce/firemip.spin0.nofire_10011231_stomate_rest.nc", "axes_name":["nav_lat","nav_lon"], "lat_reso":.5, "lon_reso":.5,

ERROR Message is as follows.

[dgoll@obelix2 ]$ ./job ./job: line 4: setenv: command not found ./job: line 5: setenv: command not found ./job: line 7: limit: command not found ./job: line 12: setenv: command not found Linux obelix2 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0] DEF directory: DEF_MICT/ running task: ['1'] results are stored at: /home/surface3/dgoll/SPINUP_ML/EXECUTION2// read variable list Traceback (most recent call last): File "main.py", line 54, in <module> varlist=json.loads(varfile.read()) File "/usr/local/install/python-3/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/local/install/python-3/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/install/python-3/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 5 column 14 (char 196)

YilongWang commented 3 years ago

Have you tried with 0.5 instead of .5

dsgoll123 commented 3 years ago

No I haven't. With 0.5 it works - Thanks Yilong

(I never thought it could make a difference if a zero is put before the point)

YilongWang commented 3 years ago

Cool to hear it works. well, different scripts have their own rules. I also not aware that .json cannot recognize .5, but just guess from the error message. Fortunately, it works :)