Skip to content

fig.coast() with just dcw kwarg fails #903

Closed
GenericMappingTools/gmt
#4815

Description

@liamtoney

Description of the problem

Using fig.coast(dcw=...) fails, asking for additional kwargs. I have to add another kwarg, like water='white', to get things to plot. I believe that dcw alone should be enough.

Full code that generated the error

import pygmt

fig = pygmt.Figure()
fig.coast(region='US', projection='S232.7435/90/8i', frame=['af', 'EWSn'], dcw='US+gred')
fig.show()

Expected output

out

Full error message

---------------------------------------------------------------------------
GMTInvalidInput                           Traceback (most recent call last)
<ipython-input-10-bd3570a700d7> in <module>
      2 
      3 fig = pygmt.Figure()
----> 4 fig.coast(region='US', projection='S232.7435/90/8i', frame=['af', 'EWSn'], dcw='US+gred')
      5 fig.show()

/opt/miniconda3/envs/roses/lib/python3.7/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    279                 if alias in kwargs:
    280                     kwargs[arg] = kwargs.pop(alias)
--> 281             return module_func(*args, **kwargs)
    282 
    283         new_module.aliases = aliases

/opt/miniconda3/envs/roses/lib/python3.7/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    423                         kwargs[arg] = separators[fmt].join(f"{item}" for item in value)
    424             # Execute the original function and return its output
--> 425             return module_func(*args, **kwargs)
    426 
    427         return new_module

/opt/miniconda3/envs/roses/lib/python3.7/site-packages/pygmt/src/coast.py in coast(self, **kwargs)
    191         raise GMTInvalidInput(
    192             """At least one of the following arguments must be specified:
--> 193             lakes, land, water, rivers, borders, Q, or shorelines"""
    194         )
    195     with Session() as lib:

GMTInvalidInput: At least one of the following arguments must be specified:
            lakes, land, water, rivers, borders, Q, or shorelines

System information

Please paste the output of python -c "import pygmt; pygmt.show_versions()":

PyGMT information:
  version: v0.0.0
System information:
  python: 3.7.9 | packaged by conda-forge | (default, Feb 13 2021, 19:53:10)  [Clang 11.0.1 ]
  executable: /opt/miniconda3/envs/roses/bin/python
  machine: Darwin-20.3.0-x86_64-i386-64bit
Dependency information:
  numpy: 1.16.2
  pandas: 1.1.5
  xarray: 0.15.0
  netCDF4: 1.5.3
  packaging: 20.9
  ghostscript: 9.53.3
  gmt: 6.1.1
GMT library information:
  binary dir: /opt/miniconda3/envs/roses/bin
  cores: 8
  grid layout: rows
  library path: /opt/miniconda3/envs/roses/lib/libgmt.dylib
  padding: 2
  plugin dir: /opt/miniconda3/envs/roses/lib/gmt/plugins
  share dir: /opt/miniconda3/envs/roses/share/gmt
  version: 6.1.1

Activity

  1. added
    bug
    on Feb 15, 2021
  2. willschlitzer commented on Feb 15, 2021

    @willschlitzer
    Contributor

    Will GMT coast just accept the E argument with no other land/water colors set? The GMTInvalidError input was likely put in to prevent an error coming back from the GMT API.

  3. seisman commented on Feb 15, 2021

    @seisman
    Member

    gmt coast -EUS+gred -pdf map works, so confirm it as a bug.

  4. added
    good first issue
    help wanted
    on Feb 15, 2021
  5. willschlitzer commented on Feb 15, 2021

    @willschlitzer
    Contributor

    Sounds good. Looks like we need to just do a quick update to the error raising.

    Less than 12 hours since v0.3.0 released and we're already coming up for changes in v0.3.1! 😂

  6. seisman commented on Feb 15, 2021

    @seisman
    Member

    Running gmt coast without extra options gives the following error messages:

    $ gmt coast -pdf map
    coast [ERROR]: Must specify -R option
    coast [ERROR]: Must specify at least one of -C, -G, -S, -I, -N, -Q and -W
    

    It doesn't mention -E, so also a tiny upstream bug.

  7. added
    upstream
    on Feb 16, 2021
  8. seisman commented on Feb 16, 2021

    @seisman
    Member

    Reopen the issue because this is also an upstream bug (if I understand it correctly).

    The fix is similar and easy. Just need to update these lines in GMT's pscoast.c: https://github.com/GenericMappingTools/gmt/blob/19db042fc2f1bf09136029bd801ea73f0b6dd30d/src/pscoast.c#L606-L609

    @willschlitzer Do you want to try it?

  9. willschlitzer commented on Feb 16, 2021

    @willschlitzer
    Contributor

    @seisman Just submitted the PR

  10. added this to the 0.3.1 milestone on Feb 16, 2021
  11. joa-quim commented on Feb 16, 2021

    @joa-quim
    Member

    Curious. I went see what I do in Julia and your command jut works (gives the map you show). But probably because under the hood I always add a -Da if option -D is not used. Though this option has no effect with DCW countries

    julia> coast(region="US", projection="S232.7435/90/8i", dcw="US+gred", show=1, Vd=2)
    "pscoast  -EUS+gred -Vq -RUS -JS232.7435/90/8i -Baf -BWSen -Da -P -K > C:\\TMP\\GMTjl_tmp.ps"
    
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

    buggood first issuehelp wantedupstream

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions