Comments (12)
from oceanmesh2d.
Most of them follow the CF conventions, so the array won't be huge: http://cfconventions.org/cf-conventions/cf-conventions.html#coordinate-types
from oceanmesh2d.
I've updated the Projection branch to support the three basic x- and y- coordinate variables names in DEM data that is CF compliant (see the arrays wkv_x and wkv_y).
Note also that I've refactored the geodata class so please let me know if things have stopped working the same way they were!
from oceanmesh2d.
Keith,
Two things to comment.
-
Longitude and Latitude words on lines 49 & 50 of
geodata.m
must be lowercase according to CF convention, or include the lowercase ones in the array as well as the title-case words. -
This part of
geodata.m
is not a good piece of code (line 400 and beyond)
Once x & y values are successfully read, you should not try to read again those values from the DEM file.
for i = 1 : length(obj.wkv_x)
try
x = double(ncread(obj.demfile,obj.wkv_x{i}));
y = double(ncread(obj.demfile,obj.wkv_y{i}));
catch
if i == length(obj.wkv_x)
error('Could not locate x/y coordinate in DEM') ;
end
end
end
I'm not so keen on Matlab because I work in C++, but something like this should solve the issue:
if ~isempty(x) && ~isempty(y)
break % Get out of the loop
end
from oceanmesh2d.
Hello Javi,
The try and catch structure is necessary in MATLAB to handle the error produced by the NetCDF wrapper.
The x and y coordinates are read twice to handle a variety of use cases (i..e, no bounding box provided, no DEM, etc.) to exit quickly. The code below 400 is to deal with the situation of a regional domain straddling the 180 meridian, which turns out to be a non-trivial problem for automatic mesh generation.
If you have code changes you'd like to incorporate please submit a pull request. Thanks.
from oceanmesh2d.
All the code under the if ~isempty(fname)
only affects when using a DEM file. The x and y should be read as many times as needed until we match the variable in the netCDF.
Right now, your code is reading the correct values and then it overwrites them. That is not the expected behavior.
from oceanmesh2d.
I reopened issue because I also believe the code is as was faulty. I just made a commit that should hopefully fix this issue. @JaviRG can you please check it works for you.
from oceanmesh2d.
What precisely was faulty?
from oceanmesh2d.
As noted by @JaviRG
Right now, your code is reading the correct values and then it [attempts to] overwrites them. That is not the expected behavior.
The break out of the loop once x and y are correctly read is better to avoid unnecessary read attempts while relying on the try and catch structure.
Perhaps faulty is not correct because it worked but my commit was aimed as at trying to avoid a clumsy try and catch and instead to search the information that is available in netcdf for reading.
Note that actual bugs were fixed too since 'fname variable' was used as the netcdfile name in ParseDEM but obj.demfile was then used for reading x and y variables, along with another ubiquitous == 0 versus isempty() catch issue.
from oceanmesh2d.
Fair enough. In the future, the person should submit a pull request and we inspect the code. I do not want to commit un tested code into the branch that's supposed to always work and then rely on users to verify it's working as expected.
from oceanmesh2d.
That's true. After testing our common examples I believe that the most recent commit should work.
As mentioned by @krober10nd we encourage a pull request for suggested code changes to accompany an issue if a plausible fix is known to the OP of the issue.
from oceanmesh2d.
Thanks @WPringle for reopening the issue and creating a new function to handle this. Now it's working properly.
In the future, the person should submit a pull request and we inspect the code.
I would be glad to contribute writing code, but as I mentioned before, I work with C++ and don't know Matlab. I think (at least) is better to open an issue and tell the authors about weaknesses in the code.
from oceanmesh2d.
Related Issues (20)
- Thalweg data format HOT 1
- Error setup.sh link m_map HOT 1
- Get stuck in using Cal_IT_Fric. HOT 13
- extra lines in fort.15 file! HOT 7
- make animation for fort.63.nc HOT 10
- meshgen.build Exiting early HOT 2
- Infinite loop when cleanup the mesh HOT 6
- Issue with using dynamic water level correction HOT 11
- Need for rapid changes in grid resolution HOT 4
- Issues with refining mesh in channels HOT 2
- Problem making fort.15 file for ADCIRC model in OceanMesh2D HOT 2
- Problem creating fort.13 file for ADCIRC model in OceanMesh2D HOT 3
- startup.sh HOT 2
- Issue regarding input files of ADCIRC model HOT 2
- How to specify the wind control and wind timestep parameters in Make_f15 function of OceanMesh2D? HOT 1
- How to make the fort.22 file for ADCIRC model? HOT 2
- Re-meshing patches function
- How to make a fort.15 file for NWS = 30 Blended GAHM & Background Gridded Wind and Pressure?
- Number of nodes and element change HOT 2
- Mesh dense changes significantly HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oceanmesh2d.