Easygrid creating grid problem

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
Chrispine

Easygrid creating grid problem

#1 Unread post by Chrispine »

Hello Everyone,
I am new to ROMS and trying to create a grid using easygrid. I can successfully create, plot, smooth bathymetry and edit mask but cannot save the grid. I get the following log when try to save. Kindly advise on how to fix the problem. I am using matlab R2014a and also installed mexcdf and scntools.


***************************************************************
** EASYGRID ***************************************************
***************************************************************

GENERATING grid...
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
> In griddata>useScatteredInterp at 184
In griddata at 125
In easygrid at 323
DONE!


GENERATING masks...
DONE!


SMOOTHING Bathymetry...

Minimum r-value = 0
Maximum r-value = 0.96934
Mean r-value = 0.056192
Median r-value = 1.4224e-17

Minimum r-value = 0
Maximum r-value = 0.67349
Mean r-value = 0.032921
Median r-value = 0

Minimum r-value = 0
Maximum r-value = 0.45822
Mean r-value = 0.027646
Median r-value = 2.6818e-05

Minimum r-value = 0
Maximum r-value = 0.38123
Mean r-value = 0.024764
Median r-value = 0.00010362

Minimum r-value = 0
Maximum r-value = 0.32907
Mean r-value = 0.022838
Median r-value = 0.00021301
Number of smoothing applications: 4
DONE!

PLOTTING grid...
DONE!
Warning: Problem writing .nc grid file. You may not have MEXCDF installed...
> In easygrid at 685
Warning: Problem writing .nc initial-conditions file. You may not have MEXCDF installed...
> In easygrid at 842


***************************************************************
elapsed time: 0.20786 minute(s)
***************************************************************
EASYGRID is DONE!!! *******************************************
***************************************************************

vilandra
Posts: 6
Joined: Thu Feb 16, 2012 5:18 pm
Location: UCLA AOS
Contact:

Re: Easygrid creating grid problem

#2 Unread post by vilandra »

I have updated easygrid's saving the bathymetry part, so that it is now compatible with Matlab's (2012a or higher) built in netcdf environment. By this way, you don't need to install mexcdf everytime you are on a new computer.

Also, please note that, I do not use the initial condition part since I have my own script for it, so I removed that option from the script.

I attached the modified easygrid and hope this helps.
Attachments
easygrid.zip
(311.1 KiB) Downloaded 429 times
Cigdem

Chrispine

Re: Easygrid creating grid problem

#3 Unread post by Chrispine »

Thanks so much. Let me try it.

Regards
Chrispine

Chrispine

Re: Easygrid creating grid problem

#4 Unread post by Chrispine »

Hi
I have tried to run the easygrid version that you provided me with. It creates a grd.nc file. However, it does display a plot and editing mask fails. It seems it the bathymetry and coastline files are not read in also. Attached is my easygrid.m, bathymetry.mat and coastline.mat files. Kindly help in diagnosing the problem.Please if possible please also share with me as script for creating initial conditions.

Best regards

Chrispine
Attachments
Lake Victoria files.zip
(594.94 KiB) Downloaded 282 times

vilandra
Posts: 6
Joined: Thu Feb 16, 2012 5:18 pm
Location: UCLA AOS
Contact:

Re: Easygrid creating grid problem

#5 Unread post by vilandra »

Hello,

I have looked the files you sent me. mexcdf libraries works for me, so I tried the original version of easygrid as well, just to make sure and it is generating the same result.

I think the problem is with your coastline file. I attached how my coastline looks like and how your looks like. It seems to me that easygrid is having problem understanding the edges of your domain. It took me a while also to generate a proper coastline file and it is not trivial (at least for me). I do not have a general script for that unfortunately, but I basically tried to follow a video tutorial from Richard Signell as far as I remember.

About initial condition: the matlab code I wrote extracts the solution from a coarser grid. Is this something you are looking for?

Thanks,
Attachments
mcr_coastline.jpg
mcr_coastline.jpg (21.74 KiB) Viewed 13593 times
lake_victoria_coastline.jpg
lake_victoria_coastline.jpg (27.02 KiB) Viewed 13593 times
Cigdem

Chrispine

Re: Easygrid creating grid problem

#6 Unread post by Chrispine »

Hi,
Thanks very much for your reply and your time. Let me try to fix the coastline before proceeding further.

Regarding the initial conditions, yeah that is the script I am looking for. I do appreciate your assistance very much.

Regards

Chrispine

Re: Easygrid creating grid problem

#7 Unread post by Chrispine »

Hi,
I have been able to successfully fix the coastline problem. With the easygrid scripts you sent me I can be able to create, plot, edit mask as well as save the grid. I have a problem in saving the in creating the initial conditions (save_init). Kindly help me out.
Regards

Chrispine

Saud
Posts: 7
Joined: Sat Oct 12, 2013 3:12 am
Location: Texas A&M University, Department of Oceanography

Re: Easygrid creating grid problem

#8 Unread post by Saud »

Hi vilandra,

Thanks for attaching the modified easygrid code. I wasn't able to save the grid in .nc using the original code because of mexcdf related issues in MATLAB. But using your modified code, the .nc grid file is created successfully. However, since you removed the initial condition part, another problem emerged that is related to writing .nc initial-conditions.
I appreciate if you attach the initial condition code you modified?

Thanks

vilandra
Posts: 6
Joined: Thu Feb 16, 2012 5:18 pm
Location: UCLA AOS
Contact:

Re: Easygrid creating grid problem

#9 Unread post by vilandra »

Hello Saud and Chrispine,

I modified easygrid again which is attached and now initial condition file generation part is also compatible with Matlab2012a an higher. I also added 2 new variables to the save_init section:
- ref_time : This is the TIME_REF in your ocean.in file.
- ocean_time : This is the DSTART in your ocean.in file (if it is 0, it means the model starts on TIME_REF).

@Chrispine: My initial condition script uses mexcdf libraries. I haven't updated it yet. Once I update it and make it compatible with Matlab2012a and higher, I will post it here.

Thanks,
Attachments
easygrid_v2.zip
(329.69 KiB) Downloaded 411 times
Cigdem

Saud
Posts: 7
Joined: Sat Oct 12, 2013 3:12 am
Location: Texas A&M University, Department of Oceanography

Re: Easygrid creating grid problem

#10 Unread post by Saud »

Thanks a lot vilandra, i really appreciate your effort and cooperation.
I'll give the new code a try.

Chrispine

Re: Easygrid creating grid problem

#11 Unread post by Chrispine »

Thanks Vilandra for the help and support.

paim_oceano
Posts: 10
Joined: Mon Jun 16, 2014 4:33 pm
Location: University of Delaware

Re: Easygrid creating grid problem

#12 Unread post by paim_oceano »

Dear Vilandra

I just wanted to thank you for sharing your easygrid_v2. I was having a lot of problems trying to run the v0 version in here but with your version it ran smoothly.

Cheers,
Andre

David_Stirling

Re: Easygrid creating grid problem

#13 Unread post by David_Stirling »

Dear All,

I've downloaded and (almost) successfully used easygrid_v2. I.e. I can write out .nc files. However, when the grid plots the bathymetry is missing, with only the grid being plotted. I was wondering if anyone had experienced a similar issue, or could suggest a possible fix for this?

Vilandra, thank you so much for your efforts with v2.

Kindest,

David

vilandra
Posts: 6
Joined: Thu Feb 16, 2012 5:18 pm
Location: UCLA AOS
Contact:

Re: Easygrid creating grid problem

#14 Unread post by vilandra »

Hello David,

Are you getting any warning/error messages? Do you have a coastline and bathymetry file? Were you able to run and generate the Fjord grid? If you give more details, it would be easier to guess what the problem is.

Cheers,
Cigdem

David_Stirling

Re: Easygrid creating grid problem

#15 Unread post by David_Stirling »

Hi Vilandra,

Thanks for your reply. Till now I have been using the Fjord example. I can plot the .mat files (bathymetry and coastline) with the same results as easygrid_v0.

However, when I run the easygrid_v2 .m file only the grid is plotted with no coastline or underlying bathymetry plotted. I do receive warnings:

***************************************************************
** EASYGRID ***************************************************
***************************************************************

GENERATING grid...
Warning: Duplicate data points have been detected and removed - corresponding
values have been averaged.
> In griddata>useScatteredInterp (line 184)
In griddata (line 125)
In easygrid (line 332)
DONE!


As a work around I have been able to run easygrid_v0 initially to define the grid and then cd to the easygrid_v2 dir and successfully write out .nc files by setting create_grid = 0 in the easygrid_v2 .m file, (using the grid produced by easygrid_v0.m).

Cheers,

David

vilandra
Posts: 6
Joined: Thu Feb 16, 2012 5:18 pm
Location: UCLA AOS
Contact:

Re: Easygrid creating grid problem

#16 Unread post by vilandra »

Hello David,

The problem is related to the spheriq_dist.m script. Please replace the one in the scripts directory with the one attached below and try it again. Let me know if it works now.

Cheers,
Attachments
spheriq_dist.m
(612 Bytes) Downloaded 318 times
Cigdem

David_Stirling

Re: Easygrid creating grid problem

#17 Unread post by David_Stirling »

Hi Vilandra,

Perfect! Thank you so much for your time and effort. The new spheriq_dist.m script file worked a treat.

Much obliged,

David :D

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Easygrid creating grid problem

#18 Unread post by neelbasak08 »

Hi Vilandra,

I am new to creating grid using Easygrid. I downloaded easygrid_v2 as in the forum and also applied all the changes discussed in this thread. My generation also ran without any error message. But my grid looks empty for the default fjord case.I am hereby attaching my photo of the grid and my easygrid_v2 package for your reference. I have my mexcdf,snctools, matlab_dir all added to matlab path correctly. Here is my user settings:

%****************************************************************************************************************************************************
% USER SETTINGS *************************************************************************************************************************************
%****************************************************************************************************************************************************

% -------------------------------------------------------------------------
% SWITCHES ( ON = 1; OFF = 0 ) --------------------------------------------
% -------------------------------------------------------------------------
create_grid = 1; % Create GRID. Turn OFF to work with a previously created grid (i.e. grid variables existing on Workspace)
plot_grid = 1; % Plot grid
smooth_grid = 1; % Smooth bathymetry using H. Arango's smth_bath.m , which applies a Shapiro filter to the bathymetry
edit_mask = 0; % Edit rho-mask using interactive plot. Use this to manually change sea-pixels into land-pixels and vice-versa
screen_output = 1; % Displays (on screen) many parameters that need to be copy-pasted in the ocean.in file
save_grid = 1; % Save GRID in a NetCDF file
save_init = 1; % Create (and save) INITIAL CONDITIONS (from grid)
% ON = 1; OFF = 0

% -------------------------------------------------------------------------
% GRID SETTINGS -----------------------------------------------------------
% -------------------------------------------------------------------------

% Geographical and Grid parameters --------
lat = 44.8125; % Latitude (degrees) of the bottom-left corner of the grid.
lon = -62.8855; % Longitude (degrees) of the bottom-left corner of the grid.

X = 9100; % Width of domain (meters)
Y = 2550; % Length of domain (meters)
rotangle = -43; % Angle (degrees) to rotate the grid conterclock-wise
resol = 100; % Cell width and height (i.e. Resolution)in meters. Grid cells are forced to be (almost) square.
N = 10; % Number of vertical levels

% Bathymetry -------------- % Bathymetry for ROMS is measured positive downwards (zeros are not allowed) see: https://www.myroms.org/wiki/index.php/G ... Bathymetry
% To allow variations in surface elevation (eg. tides) while keeping all depths positive,
% an arbitrary offset (see minh below) is added to the depth vector.

hh = nan; % Analytical Depth (meters) used to create a uniform-depth grid. If using a bathymetry file, leave hh = nan;
minh = 4; % Arbitrary depth offset in meters (see above). minh should be a little more than the maximum expected tidal variation.
Bathy = 'Fjord_bathy.mat';% Bathymetry file. If using the analytical depth above (i.e. hh ~= nan), then Bathy will not be used.
% The bathymetry file should be a .mat file containing 3 vectors (xbathy, ybathy and zbathy). where xbathy = Longitude,
% ybathy = Latitude and zbathy = depth (positive, in meters). xbathy and ybathy are in decimal degrees See: http://en.wikipedia.org/wiki/Decimal_degrees
%Bathymetry smoothing routine... See "Switches section" (above) to turn this ON or OFF
if smooth_grid == 1;
order = 2; % Order of Shapiro filter (2,4,8)... default: 2
rlim = 0.35; % Maximum r-factor allowed (0.35)... default: 0.35
npass = 50; % Maximum number of passes.......... default: 50
end
%---------------------------------


% Coastline ----------------------
Coast = load('Fjord_coast.mat'); % If there isn't a coastline file... comment-out this line: e.g. %Coast = load('Fjord_coast.mat');
% The coastline is only used for plotting. The coastline .mat file should contain 2 vectors named "lat" and "lon"


% -------------------------------------------------------------------------
% OUTPUT: File naming and NetCDF descriptors ------------------------------
% -------------------------------------------------------------------------
Grid_filename = 'Fjord'; % Filename for grid and initial conditions files (don't include extension).
% "_grd.nc" is added to grid file and "_ini.nc" is added to initial conditions file

% -------------------------------------------------------------------------
% INITIAL CONDITIONS ------------------------------------------------------
% -------------------------------------------------------------------------
if save_init == 1; % See "Switches section" (above) to turn this ON or OFF
% Initial conditions will be constant throughout the grid domain
%--------------------------------------------------------------------------
ref_date = datenum(2000,1,1,0,0,0); % TIME_REF in your ocean.in file
ocean_time = 360; % start of your ROMS model (DSTART in your ocean.in file)
NH4 = 0.1; % Ammonium concentration (millimole_NH4 meter-3)
NO3 = 10; % Nitrate concentration (millimole_N03 meter-3)
chlorophyll1 = 0.3; % Chlorophyll concentration in small phytoplankyon (milligrams_chlorophyll meter-3)
chlorophyll2 = 0.3; % Chlorophyll concentration in large phytoplankyon (milligrams_chlorophyll meter-3)
detritus1 = 0.03; % Small detritus concentration (millimole_nitrogen meter-3)
detritus2 = 0.03; % Large detritus concentration (millimole_nitrogen meter-3)
detritusC1 = 1; % Small detritus carbon concentration (millimole_carbon meter-3)
detritusC2 = 0.2; % Large detritus carbon concentration (millimole_carbon meter-3)
phyto1 = 0.02; % Small phytoplankton concentration (millimole_nitrogen meter-3)
phyto2 = 0.02; % Large phytoplankton concentration (millimole_nitrogen meter-3)
phytoC1 = 0.2; % Small phytoplankton carbon concentration (millimole_carbon meter-3)
phytoC2 = 0.1; % Small phytoplankton carbon concentration (millimole_carbon meter-3)
salt = 30; % Salinity (PSU)
temp = 9; % Potential temperature (Celsius)
u = 0; % u-momentum component (meter second-1)
ubar = 0; % Vertically integrated u-momentum component (meter second-1)
v = 0; % v-momentum component (meter second-1)
vbar = 0; % Vertically integrated v-momentum component (meter second-1)
zeta = 0; % Free-surface (meters)
zooplankton = 0.01; % Zooplankton concentration "millimole_nitrogen meter-3"
zooplanktonC = 0.5; % Zooplankton carbon concentration "millimole_carbon meter-3"
%--------------------------------------------------------------------------
end



%****************************************************************************************************************************************************
% END OF USER SETTINGS ******************************************************************************************************************************
%****************************************************************************************************************************************************



Any help from you is actually appreciated.

Thank you in advance

Neel
Attachments
Screenshot 2021-01-06 231155.jpg
easygrid_v2_up.zip
(518.76 KiB) Downloaded 147 times

luhputria
Posts: 14
Joined: Tue Mar 31, 2020 3:43 am
Location: The University of Western Australia

Re: Easygrid creating grid problem

#19 Unread post by luhputria »

Hi all,

I am a new user using easygrid.
Before I just used ana_grid.h in ROMS to try test case.
Right now, I want to create my own grid, it's similar with estuary test case in ROMS but this rectangular domain has sinusoidal seabed.
And I want to use width and length of domain data only without lat and lon data.
Anyone here can give me some advice how to create sinusoidal seabed in my easygrid?

Thanks before.

Regards,
Luh

Post Reply