OpenDrift / opendrift

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

LCS ROMS #783

Open MireyaMMO opened 2 years ago

MireyaMMO commented 2 years ago

Hi! I've been testing the backtracking LCS script on a ROMS grid, at first I struggled because the fake projection (due to the lack of projection from ROMS) wasn't transforming correctly. That was fixed creating my own projection and adding it to the reader, but something is still off because I'm still getting data over masked locations. Do you mind sharing any suggestions?

This is a 7-day backtrack simulation on a 1 km resolution grid LCStest

knutfrode commented 2 years ago

A bit busy the next two days, but a quick comment in the meantime: OpenDrift will automatically extrapolate fields to fill gaps between the valid data (ocean pixels) and the coastline (typically GSHHG, and independent). Thus you should somehow re-impose a landmask (masked data) as variable land_binary_mask from your reader (or another reader). Hope this helps.

On Tue, Nov 30, 2021, 09:16 MireyaMMO @.***> wrote:

Hi! I've been testing the backtracking LCS script on a ROMS grid, at first I struggled because the fake projection (due to the lack of projection from ROMS) wasn't transforming correctly. That was fixed creating my own projection and adding it to the reader, but something is still off because I'm still getting data over masked locations. Do you mind sharing any suggestions?

https://drive.google.com/file/d/1t8z6r7nXoGjmXRxEwav5MIJhEGVk8Da1/view?usp=sharing http://url

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OpenDrift/opendrift/issues/783, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABH25IZS2UWZDOJ3R5WYHWTUOSB5FANCNFSM5JBEE7BA . 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.

MireyaMMO commented 2 years ago

Thank you very much for taking time to reply! So far I believe I've done this. As extra information this is the configuration I've set regarding the mask o.set_config('seed:ocean_only',True) o.set_config('environment:fallback:land_binary_mask', 0) I also tried adding one reader just for the mask but got the same result.

According to the log, It's loading from the ROMS reader and moving the points that are considered to be land so this tells me the mask is being read correctly.

10:15:26 DEBUG opendrift.models.basemodel: Preparing roms native 10:15:26 DEBUG opendrift.readers.basereader: Nothing more to prepare for roms native 10:15:26 INFO opendrift.models.basemodel: Using existing reader for land_binary_mask 10:15:26 DEBUG opendrift.models.basemodel: ---------------------------------------- 10:15:26 DEBUG opendrift.models.basemodel: Variable group ['land_binary_mask'] 10:15:26 DEBUG opendrift.models.basemodel: ---------------------------------------- 10:15:26 DEBUG opendrift.models.basemodel: Calling reader roms native 10:15:26 DEBUG opendrift.models.basemodel: ---------------------------------------- 10:15:26 INFO opendrift.models.basemodel: Moving 10381 out of 123380 points from land to water

And also it seems like it's masking values that are stranding

10:24:01 DEBUG opendrift.models.basemodel: Using fallback value 0.0 for land_binary_mask for 31888 elements 10:24:01 DEBUG opendrift.models.basemodel: ------------ SUMMARY ------------- 10:24:01 DEBUG opendrift.models.basemodel: land_binary_mask: 0 (min) 1 (max) 10:24:01 DEBUG opendrift.models.basemodel: ---------------------------------

If I print the reader I have two variables of land_binary_mask, don't know if that could be an issue and if it is not sure of how to delete one.

print(reader) Reader: roms native Projection: None Coverage: [pixels] xmin: 0.000000 xmax: 399.000000 step: 1 numx: 400 ymin: 0.000000 ymax: 314.000000 step: 1 numy: 315 Corners (lon, lat): (175.70, -35.27) (180.25, -35.27) (175.70, -38.06) (180.25, -38.06) Vertical levels [sigma]: [-0.98494898 -0.95515306 -0.92576531 -0.89678571 -0.86821429 -0.84005102 -0.81229592 -0.78494898 -0.7580102 -0.73147959 -0.70535714 -0.67964286 -0.65433673 -0.62943878 -0.60494898 -0.58086735 -0.55719388 -0.53392857 -0.51107143 -0.48862245 -0.46658163 -0.44494898 -0.42372449 -0.40290816 -0.3825 -0.3625 -0.34290816 -0.32372449 -0.30494898 -0.28658163 -0.26862245 -0.25107143 -0.23392857 -0.21719388 -0.20086735 -0.18494898 -0.16943878 -0.15433673 -0.13964286 -0.12535714 -0.11147959 -0.0980102 -0.08494898 -0.07229592 -0.06005102 -0.04821429 -0.03678571 -0.02576531 -0.01515306 -0.00494898] Available time range: start: 2020-10-01 00:00:00 end: 2020-11-01 00:00:00 step: 1:00:00 745 times (0 missing) Variables: sea_floor_depth_below_sea_level land_binary_mask land_binary_mask sea_surface_height x_sea_water_velocity y_sea_water_velocity upward_sea_water_velocity sea_water_temperature sea_water_salinity surface_downward_x_stress surface_downward_y_stress

0:03:46.0 total 0:00:00.7 preparing 0:02:29.5 reading 0:00:54.3 interpolation 0:00:00.5 interpolation_time 0:00:01.8 masking 0:01:13.5 rotating vectors

Also I tried to plot the reader using reader.plot('land_binary_mask') but I got an error due to the projection

Thank you again

*Adding the image again to show the reader's coastline LCStest3

knutfrode commented 2 years ago

if reader.plot() does not work, it could indicate that your code is slightly outdated. Could you try to update your code (git pull) and also the dependencies with:

conda env update -f environment.yml
pip install -e .

It might not solve the problem, but would be useful to see the plot of landmask.

MireyaMMO commented 2 years ago

Thanks! I updated everything, still having error but it's because I'm working in a New Zealand domain and the program has problems with the limits of 180.5, still I worked a little bit around it and managed to get the plot going landmask landmask2

knutfrode commented 2 years ago

Yes, I believe the ROMS reader is less robust than reader_netCDF_CF_generic regarding dateline problems.

Anyway, is there a particular reason for adding this line? o.set_config('environment:fallback:land_binary_mask', 0) Can you try without this?

It is not quite clear to me what is the problem, is it that you get LCS-values calculated over land come places? Could this be particles "jumping" into the land during the a time step (which should preferably not be greater than 30 minutes here. But it also seems that you have missing data (white area) over sea here?

MireyaMMO commented 2 years ago

From my understanding that line means that outside the domain there's ocean (might be wrong), this is a nested domain, so that's why I added it. I did some tests without it but it still shows data on land.

LCStest30m2

Yes that's the problem. I think it's a big area of in land particles, considering the 1 km resolution grid initially given, (another time period given below). I did try a smaller time-step. There's no noticeable difference between 15 minute time-step and a 30 minute time-step, in terms of the gap over sea and the data in land.

LCStest30Jul