Giter VIP home page Giter VIP logo

Comments (14)

PaulWessel avatar PaulWessel commented on June 5, 2024

We could fix the macro to do this

#define gmt_M_file_is_memory(file) (file && !strncmp (file, "@GMTAPI@-", GMTAPI_PREFIX_LEN) && strlen (file) >= GMTAPI_MEMFILE_LEN)

That way it will be recognised even if there are?[layer]at the end (>= vs ==).

Next, we allow the @GMTAPI@-S-I-U-U-U-N-000035?[0] filename to be passed without scrutiny and then grdtrack will call GMT_Read_Data and then gmtapi_import_grid will need a new trick to point to that layer. I think `@GMTAPI@-S-I-U-U-U-N-000035?[layer] should be allowed. I can imagine you also passing layer n of a stack to grdimage etc.

If course, you could probably do this in Julia and pass a grid instead of a cube layer, but what fun is it in that?

from gmt.

PaulWessel avatar PaulWessel commented on June 5, 2024

How do a load in a cube? Tried

C = gmtread("cube.nc",cube=true);
but your gmtread docs do not mention cube, but have no error.

but grdinterpolate sees it as a grid.

grdinterpolate(C, S=[5.5 4.5])
grdinterpolate [ERROR]: Input memory reference is not a cube!

@GMTAPI@-S-I-G-G-G-N-000002 seems to come from Julia since it is in the opt array.

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

I think we have to read cubes with gdalread instead of gmtread. The case I debugged was with a cube that was already in memory after creating it from a list of geotiff grids.
Wont be able to confirm more things before the afternoon.

from gmt.

PaulWessel avatar PaulWessel commented on June 5, 2024

Ok, when back please give me steps so I can run either my or your command.

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

C = gmtread("cube.nc",cube=true);
but your gmtread docs do not mention cube, but have no error.

Given the way the keyword/values work no kwarg pair is actually an error if the parsing in the program doesn't catch the specific case. And because the number of possible errors is infinite what I do is that I consume all valid options and at the end if there are unconsumed I report that as a warning that is a strong indicator of user mistake. This works fine in pure modules but become quite complicated in modules that call other modules (gmtread became quite complex).

Anyway, it turns out that you can use grdinterpolate to import the cube into memory. i.e.,

C = grdinterpolate("cube.nc")

and then do the

grdinterpolate(C, S=[5.5 4.5])

from gmt.

PaulWessel avatar PaulWessel commented on June 5, 2024

I did that, but C seems to be a grid. Dont we want it to be a cube? How (in Julia) can I tell the dimensions of C?

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

No, you did gmtread("cube") and that reads just one layer (needs fix). What I'm saying is to grdinterpolate("cube") and that gives a cube. Possibly not intended but it does what's is needed here. Other option is to update GMT.jl to have the (incomplete) fix that I just committed and do C = gdalread("cube")

from gmt.

PaulWessel avatar PaulWessel commented on June 5, 2024

Sure, that works, but dont we want passing a cube layer to work down the road?

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

But passing a cube layer is just like passing a grid to grdtrack, what would be tested here? What I was expecting is to pass the entire cube at once and have all layers be tracked.

To take slices of a cube see ? slicecube on the Julia cmd or https://www.generic-mapping-tools.org/GMTjl_doc/documentation/utilities/slicecube/index.html#slicecube
basically. G = slicecube(cube, n)

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

If this is all too complicated, leave it. I think I can program the grdinterpolate -S directly in Julia.

from gmt.

PaulWessel avatar PaulWessel commented on June 5, 2024

I see, so you cannot do something like C{0} to get grid layer 0. I was imagining people with cubes wanting to pass slices like cube[3] to grdimage and we would then need to handle that slicing in gmtapi_import_grid.

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

Sure we can. I said it above. One can do slicecube(cube, 1) and pass first layer. It has to be a function and not just C[1] because that's just the first element of the 3D array. And it can't neither (well, it can) be C[:,:,1] that looses all grid's metadata and passes just a raw 2D matrix. But when we pass a single layer it's a grid that is being passed and not a cube with only one layer (a needless complicated entity).

from gmt.

PaulWessel avatar PaulWessel commented on June 5, 2024

So close this or?

from gmt.

joa-quim avatar joa-quim commented on June 5, 2024

Yes better close, though this may strike again in another circumstance. I hope that then we will still remember about this.

from gmt.

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.