OpenDrift / opendrift

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

Lazy reader using ROMS native reader #882

Open taoansf opened 2 years ago

taoansf commented 2 years ago

Hello,

I would like to know if it is possible to set the method add_readers_from_list to read a ROMS native netcdf file list? However I need to use the method reader_ROMS_native.Reader instead of the default netcdf generic reader.

With best regards,

Taoan

knutfrode commented 2 years ago

Hi, Yes, this should work well.

On Wed, Mar 16, 2022, 22:16 taoansf @.***> wrote:

Hello,

I would like to know if it is possible to set the method add_readers_from_list to read a ROMS native netcdf file list? However I need to use the method reader_ROMS_native.Reader instead of the default netcdf generic reader.

With best regards,

Taoan

— Reply to this email directly, view it on GitHub https://github.com/OpenDrift/opendrift/issues/882, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABH25I3FJKYQT5XLNQ7OMYLVAJFSLANCNFSM5Q5B3JWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

taoansf commented 2 years ago

Hello, thank you for your support.

I have some doubts after try this: 1- Create a list of reader_ROMS_native.Reader objects 2- o.add_readers_from_list(listforceroms)

I got this error message File "/home/taoan/miniconda3/envs/opendrift/lib/python3.9/site-packages/opendrift/readers/reader_lazy.py", line 31, in init self._lazyname = 'LazyReader: ' + args[0]

TypeError: can only concatenate str (not "Reader") to str

I think the lazy reader function .add_readers_from_list does not work with reader_ROMS_native.Reader objects.

Do you have any suggestion how to use .add_readers_from_list with reader_ROMS_native.Reader ?

With best regards,

Taoan

knutfrode commented 2 years ago

Hi,

The list should contain filenames/URLs, and not reader objects.

taoansf commented 2 years ago

Yes, I understand about filenames/URL

My problem is that if I give only filenames the opendrift reads that like generic netcdf readers, not like roms native. I also observed that if I use o.add_readers(listforceroms) the opendrift runs ok, but I dont know if it is working like lazy readers or not.

Thank you for your help.

knutfrode commented 2 years ago

Ok, yes some ROMS-files may in fact be parsable by the generic netCDF-reader, which might not be what you want. But you may also add the readers one by one:

o.add_reader(reader_one)
o.add_reader(reader_two)
taoansf commented 2 years ago

Ok, is there some particular flag to put on my netcdf files to be auto recognized as ROMS-file?

knutfrode commented 2 years ago

Can you post an ncdump of such a ROMS file, or eventually make a small sample available?

taoansf commented 2 years ago

Hello,

You can get a sample file by this link https://drive.google.com/file/d/1KWn6LwxqR4fkVGx2Uh9TO7oJcGI0jbd3/view?usp=sharing