Skip to content

grdmath for externals seems to only accept input grids, not lines #2476

Closed

Description

@joa-quim
julia> G = gmt("grdmath -R60/95/6/24 -I0.1 ? LDIST", mat2ds([73 24; 89 6]))
ERROR: grd_init: input (Array{GMT.GMTdataset,1}) is not a GRID container type

bu it works if I first save the the line into a file and next do

julia> G = gmt("grdmath -R60/95/6/24 -I0.1 line.dat LDIST")

Activity

  1. changed the title [-]grdmath for externals seam to only accept input grids, not lines[/-] [+]grdmath for externals seems to only accept input grids, not lines[/+] on Jan 19, 2020
  2. PaulWessel commented on Jan 20, 2020

    @PaulWessel
    Contributor

    Yes, that is the thinking. So you can experiment with this. In gmt_api.c around line 10675 we state

    info[n_items].option    = opt;
    info[n_items].family    = family;
    info[n_items].geometry  = geometry;
    info[n_items].direction = direction;
    

    I think we may need something like this:

    if (is_grdmath && opt->previous && !strcmp (opt->previous->arg, "LDIST")) {
        info[n_items].family    = GMT_IS_DATASET;
        info[n_items].geometry  = GMT_IS_LINE;
    }
    
    

    There are several of these operators (LDIST2? PDIST? etc) and some are LINE and others are POINT. If the above works then maybe generalize this in to a

    GMT_LOCAL void check_grdmath_type (struct GMT_OPTION *opt, struct GMT_RESOURCE *item) {
        if (!opt) return;
        if (!strcmp (opt->arg, "LDIST"))
            item->family = GMT_IS_DATASET, item->geometry=GMT_IS_LINE;
       else if ...
    
    }
    

    and call as

    if (is_grdmath) check_grdmath_type (opt->previous, info[n_items])

    you can set is_grdmath to true earlier in that functions when we check if grdmath is called.

  3. joa-quim commented on Jan 20, 2020

    @joa-quim
    MemberAuthor

    I made it

    			if (!strncmp (module, "grdmath", 7U) && opt->previous && !strcmp (opt->previous->arg, "LDIST")) {
    			    info[n_items].family    = GMT_IS_DATASET;
    			    info[n_items].geometry  = GMT_IS_LINE;
    			}
    			else {
    				info[n_items].family    = family;
    				info[n_items].geometry  = geometry;
    			}
    

    but still get the same error.

  4. PaulWessel commented on Jan 20, 2020

    @PaulWessel
    Contributor

    Sorry, the principle is good I think. Deep in movie title and fading. Make me a matlab script that shows the same failure and if you are lucky I will have time later.

  5. joa-quim commented on Jan 20, 2020

    @joa-quim
    MemberAuthor

    The Ml version should be almost equal

    G = gmt('grdmath -R60/95/6/24 -I0.1 ? LDIST', [73 24; 89 6])
    
  6. PaulWessel commented on Jan 21, 2020

    @PaulWessel
    Contributor

    See #2484. Some progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions