MET-OM / metocean-api

Extract time series of metocean data from global/regional/coastal hindcasts/reanalysis
GNU Lesser General Public License v2.1
4 stars 5 forks source link

Update Timeseries lat, lon when finding nearest? #8

Closed ketilt closed 2 months ago

ketilt commented 10 months ago

Given that the user provides coordinates far out of bounds to the TimeSeries constructor, When calling TimeSeries.import_data, the function get_near_coord locates the nearest relevant grid cells, Then the user provided coordinates are still kept in TimeSeries.lat, TimeSeries.lot and TimeSeries.datafile And the real data coordinates are not available as variables in the code

In my application, I want to plot graphs of the extracted data, and use the real coordinates in the graph title.

So the question is, should lat and lon be updated when they are modified; or can the used coordinates be returned to the user in another way? This is further complicated in the case of NORA3_wind_wave, where different coordinates may be used for wind and wave variables.

Example output, with user provided coordinate inland in South America:

Directory  cache  already exists
https://thredds.met.no/thredds/dodsC/nora3_subset_wave/wave_tser/202001_NORA3wave_sub_time_unlimited.nc
Find nearest point to lon.=-60.33449193071423,lat.=-25.414569791975136
Found nearest: lon.=-13.033509,lat.=54.479645

Directory  cache  already exists
https://thredds.met.no/thredds/dodsC/nora3_subset_atmos/wind_hourly/arome3kmwind_1hr_202001.nc
Find nearest point to lon.=-60.33449193071423,lat.=-25.414569791975136
Found nearest: lon.=-30.167999887837368,lat.=54.2909997971533
Data saved at: NORA3_wind_wave_lon-60.33449193071423_lat-25.414569791975136_20200101_20200131.csv

Using metocean-api 1.1.0.

KonstantinChri commented 2 months ago

Hi, Thanks for mentioning this, it is fixed in version 1.1.5. In case the requested point is out of the model domain (> 50 km), it raises a ValueError.