OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
250 stars 120 forks source link

Unable to add reader from a local file and import landmask #337

Closed mevo-creator closed 3 years ago

mevo-creator commented 4 years ago

Hello Team, First of all, Congratulations and thanks so much for developing easy to use open source trajectory modelling software. I'm new to python and hope i can use this software for my PhD research here at University of Stavanger in Norway. I've installed Opendrift and trying to run tutorials and examples. However, when running tutorials, I'm getting error when trying to add reader from a local file and also when trying to import landmask. Can someone please guide me about this issue. I'm pasting errors below. Thanks in advance!

-------------Error while trying to add reader from a local file--------------

reader_norkyst = reader_netCDF_CF_generic.Reader('norkyst800_16Nov2015.nc') 13:40:31 INFO: Opening dataset: norkyst800_16Nov2015.nc 13:40:31 INFO: Opening file with Dataset Traceback (most recent call last): File "C:\Users\mevo.conda\envs\opendrift\lib\site-packages\opendrift\readers\reader_netCDF_CF_generic.py", line 142, in init self.Dataset = Dataset(filename, 'r') File "netCDF4_netCDF4.pyx", line 2321, in netCDF4._netCDF4.Dataset.init File "netCDF4_netCDF4.pyx", line 1885, in netCDF4._netCDF4._ensure_nc_success FileNotFoundError: [Errno 2] No such file or directory: b'norkyst800_16Nov2015.nc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "C:\Users\mevo.conda\envs\opendrift\lib\site-packages\opendrift\readers\reader_netCDF_CF_generic.py", line 144, in init raise ValueError(e) ValueError: [Errno 2] No such file or directory: b'norkyst800_16Nov2015.nc'

-------------------- Error when importing landmask--------------------

reader_landmask = reader_global_landmask.Reader( ... extent=[2, 8, 59, 63]) 13:43:39 DEBUG: Adding new variable mappings ERROR:root:could not verify read permissions for group and others on landmask. Traceback (most recent call last): File "C:\Users\mevo.conda\envs\opendrift\lib\site-packages\opendrift_landmask_data-0.6-py3.8.egg\opendrift_landmask_data\mask.py", line 77, in __check_permissions__ if not os.stat(self.lockf).st_mode & 0o777 == 0o777: FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\Users\mevo\AppData\Local\Temp\landmask\.mask.dat.lock'

knutfrode commented 4 years ago

Yes, it seems to be a Windows issue. It is a bit hard for me to debug this one since I have no Windows machine available, and also since days are quite busy.

But perhaps you can try in the meantime yourself to find a workaround (in reader_ROMS_native.py) according to discussions like the following? https://github.com/usgs/libcomcat/issues/184

mevo-creator commented 4 years ago

ok. I'll try to go through the discussion to find a way. I am a beginner in python so not sure how much I could achieve but I'll give it a try :) Thanks!

mevo-creator commented 3 years ago

Hi @knutfrode , The above issue related to windows got solved by itself in Opendrift version 1.4.2.

I've another query if you could guide me with. From literature studies, we have found that the sunlight (weathering) is responsible for breaking down of polymers over a period of time. However, the impact of solar irradiation changes with latitude and depth in the water column. We are trying to use Opendrift for analysing how the number of particles are changing with depth. Basically, trying to see at what depth the majority of particles end up after each time step. Is there any plotting/analysis tool within Opendrift that can give us output in terms of statistics (numbers) of particles at different depths? For instance, if 200000 particles are seeded and tracked for a year, after each time step what percentage of particles are between 0 and 10m, 10 and 20m and so on.

I did find an interesting plotting method o.animate_vertical_distribution(bins=30) in this example however this only works in Openoil and not in Oceandrift (the plotting takes a very long time in Oceandrift and not all time steps get plotted). I also tried some other plotting method that you'd suggested earlier for instance o.plot_property('z') or o.plot_vertical_distribution() however these methods generates plots of all particles that are seeded/tracked in the simulation and don't give statistics in terms of pure numbers. Is there some command/other approaches by which we can get numbers for eg percentage of total particles between 0 and 10, 10 and 20 and so on at different time steps? Please let me about this. Thanks

knutfrode commented 3 years ago

There are no specific methods to provide such statistics, but this should be fairly straightforward to do as post-processing from the history-array.

animate_vertical_distribution should work the exact same way for OceanDrift as for OpenOil, but it might be slow for many particles (as with any plotting/animation method). It should also plot every output time step (which may be larger than calculation time step).

mevo-creator commented 3 years ago

ok. I would imagine so since the position of particles is stored in the output file at each time step. But how can we approach this post-processing from history-array. Do we need to import the position of particles from output file and make our own analysis method? it would be helpful if you could explain this briefly on how we could approach this?

I'll wait for more time for plotting animate_vertical_distribution

knutfrode commented 3 years ago

If you import the simulation to an object o, you can get the depths by z = o.get_property('z')[0], with dimensions (output_timestep, particle_number)

This is also stored the same way as variable z in the netCDF-file.

From there you would need to make your own analysis method for what you want to achieve.

mevo-creator commented 3 years ago

Ok. I will try and implement this approach. Thank you for your guidance.

mevo-creator commented 3 years ago

Hi @knutfrode , I need to understand the resolution of the SVIM currents data set inorder to refer it in the publication ('https://thredds.met.no/thredds/dodsC/nansen-legacy-ocean/svim_daily_agg') that we are using as a reader in this simulation. I found this link SVIM that archives the data set. Also, this publication that explains how the SVIM data was generated. Lienetal2013-EvaluationofaNordicSeas4kmnumericaloceanmodelhindcastarchiveSVIM1960-2011 (1).pdf

I need to know if this is the right link and publication corresponding to SVIM data set, please confirm this. Thanks

knutfrode commented 3 years ago

I can confirm that this is the right link and reference. You may also mention that you accessed the data through thredds.met.no

mevo-creator commented 3 years ago

Thank you so much for quick response!

gauteh commented 3 years ago

Closing, re-open if needed.