iamsaswata / imdlib

Download and process binary IMD meteorological data in Python
https://imdlib.readthedocs.io
MIT License
30 stars 16 forks source link

to_csv add lat and lon if None is selected #3

Closed pratiman-91 closed 4 years ago

pratiman-91 commented 4 years ago

import imdlib as imd

start_yr =2018 end_yr = 2018 variable = 'rain' # other options are ('tmin'/ 'tmax') data = imd.open_data((start_yr, end_yr), 'rain','yearwise') data.to_csv('test.csv') Traceback (most recent call last): File "", line 1, in File "C:\ProgramData\Miniconda3\lib\site-packages\imdlib\core.py", line 77, in to_csv self.lat_array, self.lon_array) File "C:\ProgramData\Miniconda3\lib\site-packages\imdlib\util.py", line 26, in get_lat_lon lat_index = np.abs(lat_rage - lat).argmin() TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

iamsaswata commented 4 years ago

Thanks for reporting it. This was happening due to there was no support earlier for converting the entire 3D data array to 2D data format (with lat and lon as None).

Now this has been fixed. We have added this feature with 11619a3476f2ae0474cbc62088455d9bfc6c0819. This modification is added at https://github.com/iamsaswata/imdlib/blob/master/imdlib/core.py#L94-L99

pratiman-91 commented 4 years ago

Makes sense.