Giter Site home page Giter Site logo

Comments (12)

krober10nd avatar krober10nd commented on May 27, 2024

from oceanmesh2d.

 avatar commented on May 27, 2024

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.

krober10nd avatar krober10nd commented on May 27, 2024

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.

 avatar commented on May 27, 2024

Keith,

Two things to comment.

  1. 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.

  2. 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.

krober10nd avatar krober10nd commented on May 27, 2024

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.

 avatar commented on May 27, 2024

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.

WPringle avatar WPringle commented on May 27, 2024

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.

krober10nd avatar krober10nd commented on May 27, 2024

What precisely was faulty?

from oceanmesh2d.

WPringle avatar WPringle commented on May 27, 2024

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.

krober10nd avatar krober10nd commented on May 27, 2024

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.

WPringle avatar WPringle commented on May 27, 2024

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.

 avatar commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.