uafgeotools / rtm

A Python package for locating infrasound sources using reverse time migration
https://uaf-rtm.readthedocs.io/
MIT License
38 stars 13 forks source link

Xarray to netcdf problem when an attribute is a dict #18

Closed davidfee5 closed 4 years ago

davidfee5 commented 4 years ago

in travel_time.py, dem.to_netcdf(FDTD_DIR+FILENAME_ROOT+'.nc') gives the error: ...

TypeError: Invalid value for attr: {'zone': 59, 'southern_hemisphere': True} must be a number, a string, an ndarray or a list/tuple of numbers/strings for serialization to netCDF files

Just deleted the 'UTM" attr for now. Maybe break it up into two attrs?

liamtoney commented 4 years ago

I forgot about the pains of using non-standard attributes. Maybe pickle is the way to go after all. I don't really see a problem since if the user has an aged pickle file that's not compatible with newer xarray they can always create a new one (using their newer xarray version) by running prepare_fdtd_run()again. I don't anticipate it being a problem.

davidfee5 commented 4 years ago

Yeah, I'd like to use netcdf if possible. Let's poke around a bit. Running prepare_fdtd_run() again would be a bit of pain and more chance to mess something up

liamtoney commented 4 years ago

Per our conversation just now, we can avoid this issue in by using pickle files to capture the FDTD grid geospatial data. We will still have to deal with using netCDF files for the newly desired "read in a netCDF file if present" option for fdtd_travel_time() however

liamtoney commented 4 years ago

Fixed in 473a69b. Will make a new issue for the netCDF travel time array saving enhancement