Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Leonardo Uieda
    @leouieda
    There is some issue with the metadata in the netCDF export but to my knowledge GMT doesn't read projection info from the netCDF grids either.
    Mark Wieczorek
    @MarkWieczorek
    Thanks. axarray's to_netcdf() seems to work fine, but there is one small problem: when I use grdinfo, it doesn't provide the maximum and minimum values for the z coordinate. Do you know if there is a way to do this?
    $ grdinfo test.grd
    grdinfo: Warning: Parameter TIME_LANGUAGE is deprecated. Use GMT_LANGUAGE instead.
    Please see http://gmt.soest.hawaii.edu/doc/5.4.5/GMT_Docs.html#new-features-in-gmt-5 for more information.
    test.grd: Title: 
    test.grd: Command: 
    test.grd: Remark: 
    test.grd: Gridline node registration used [Geographic grid]
    test.grd: Grid file format: nf = GMT netCDF format (32-bit float), COARDS, CF-1.5
    test.grd: x_min: 0 x_max: 359.875 x_inc: 0.125 name: Longitude n_columns: 2880
    test.grd: y_min: -89.875 y_max: 90 y_inc: 0.125 name: Latitude n_rows: 1440
    test.grd: z_min: 0 z_max: 0 name: Mars Topography
    test.grd: scale_factor: 1 add_offset: 0
    test.grd: format: classic
    Leonardo Uieda
    @leouieda
    The problem is that grdinfo isn't really reading the data and finding those values. It takes them from the header (and doesn't check so you probably shoulnd't rely on that output).
    But you can use the -L0 option to get GMT to actually look at the data: http://www.generic-mapping-tools.org/gmt/latest/grdinfo.html
    Mark Wieczorek
    @MarkWieczorek
    Ok. That works. But that begs the question: can I set the header somehow myself with xarray?
    Leonardo Uieda
    @leouieda
    Yep. The xarray classes have a attrs attribute that is a dictionary of metadata. Whatever you put in there is saved to the header of the netCDF file.
    Beware that you should use str values only in the dict to avoid errors. And xarray doesn't preserve that metadata for many computations on the data because they can't guarantee that the metadata is still correct.
    Mark Wieczorek
    @MarkWieczorek
    setting attrs={'z_min': '-9.0', 'z_max': '9.0'} seems to give the same result with grdinfo.
    Do you know what the name of the attribute is that grdinfo takes for the z_min and z_max values?
    Liam Toney
    @liamtoney

    There is some issue with the metadata in the netCDF export but to my knowledge GMT doesn't read projection info from the netCDF grids either.

    @leouieda I guess I learned something new today!

    Liam Toney
    @liamtoney
    @MarkWieczorek I haven't tried this myself, but you might be able to find out what the attribute names are by calling xarray.open_dataset on a known grid file. I believe that the resulting Dataset object will contain the grid file's attributes as seen via grdinfo
    Liam Toney
    @liamtoney

    @MarkWieczorek Okay, I think I've determined how you might modify the z_min and z_max values. MWE:

    import xarray as xr
    ds = xr.open_dataset('foo.grd')
    ds.z.attrs['actual_range'] = [-9.0, 9.0]
    ds.to_netcdf('bar.grd')

    The key here is setting the attributes of the z variable (or whatever it's called), not those of the overall Dataset.

    Leonardo Uieda
    @leouieda
    @liamtoney beat me to it :)
    Mark Wieczorek
    @MarkWieczorek
    Thanks, that was what I was looking for. Here is my solution:
    gxr = xr.DataArray(grid.to_array(), dims=('Latitude', 'Longitude'), coords={'Latitude': grid.lats(), 'Longitude': grid.lons()}, name='Mars Topography', attrs={'actual_range': [grid.min(), grid.max()]})
    gxr.to_netcdf('test.grd')
    Mark Wieczorek
    @MarkWieczorek
    Also, in order to set the "title" and "remark" attributes output by grdinfo, you next need to convert this to an xarray dataset, and then set the attrs "title" and "description".
    Liam Toney
    @liamtoney
    Glad you got it working!
    Leonardo Uieda
    @leouieda
    :+1: I sometimes had trouble using a non-str value in attrs but I'm sure when/if it breaks.
    Ben Ashman
    @bashman937_gitlab

    Hi all! I'm new to pygmt. Is there a way to add titles to plots? I've dug around the other Gitter page and Github, but apologies if I missed this somewhere. Also my axis labels don't seem to show up. For example:

    figd.plot(x=lon,y=lat,J="W0/6i",R=region,color=colors,style='c0.1c',frame=['xg60+l"longitude"', 'yf5g30a60+l"latitude"'],cmap="viridis")

    I'm not seeing "latitude" or "longitude"

    Dongdong Tian
    @seisman
    @bashman937_gitlab You can change the frame to frame=['xg60+l"longitude"', 'yf5g30a60+l"latitude"', '+t"This is title"'] to add a title to your plot. GMT cannot add any labels to geographic plots, because the X axis is always longitude and Y axis is always latitude for geographic projections. It's a "feature" of GMT, not a bug. If you really want to add "latitude" or "longitude", you have to use pstext to add them manually. However, the text function hasn't been implemented in pygmt.
    @bashman937_gitlab BTW, Figure.plot() sometimes cannot plot lines correctly. It's a known and unsolved bug. See GenericMappingTools/pygmt#255 for details.
    Ben Ashman
    @bashman937_gitlab
    thank you, @seisman !
    Eric Fielding
    @EJFielding
    Hi, I am new to pygmt.
    Eric Fielding
    @EJFielding
    I am not using Anaconda, so I used the "pip install" method. I can import pygmt and run the pygmt "first-figure.py" commands in my Jupyter window. I see the map but it is only showing half of it both on the screen and when I use the "savefig" function.
    Eric Fielding
    @EJFielding
    Is this likely a bug or something that is off in my configuration? I don't see a way to upload an image here.
    I had another question, I was trying to run data = pygmt.datasets.load_japan_quakes() and I got an error message. I notice that gmt.soest.hawaii.edu is offline at the moment. Does all the data come from that server?
    `
    Liam Toney
    @liamtoney
    Thanks for making an issue on GitHub, Eric. I've responded to it there.
    (As an aside, I see from your profile that you do SAR stuff. I'm currently working with Franz Meyer at UAF to bring in some GMT tools to the SARVIEWS framework. Let me know if you have any ideas or "wish list" items for the SARVIEWS user interface!)
    Eric Fielding
    @EJFielding
    @liamtoney Yes, I work on SAR and InSAR. I only looked at SARVIEWS once or twice as I work with the JPL ARIA project and use their products for most of my InSAR needs. The ARIA data products website (new one is ARIA products) uses Leaflet to show preview images so they can be zoomed, etc.
    Leonardo Uieda
    @leouieda
    @EJFielding thanks for bringing this up! It's good to have people with different setups trying things. I'll follow up on #291
    Stefano
    @steo85it
    Hi! Very nice and useful initiative. I'm implementing laser altimetry simulations in python and happen to need the GMT grdtrack function to extract elevation data from a topography basemap. Is this function already implemented in pygmt or do you plan to implement it at some point? Thanks!
    Leonardo Uieda
    @leouieda
    Hi @steo85it, grdtrack is still not implemented by we intend to have all of GMT accessible in the future. We're focusing more on establishing a basis for the package right now than implementing everything. That said, we are open for contributions and would more than welcome your knowledge and use case when designing the grdtrack function. Keep posted on the Github repository https://github.com/GenericMappingTools/pygmt
    Stefano
    @steo85it
    @leouieda Ok, thanks! Makes total sense to proceed in this way. I'll just "subprocess" grdtrack for the moment, then, but keep track of your advances and eventually help when it'll be time. Cheers!
    Leonardo Uieda
    @leouieda
    :+1:
    Charles
    @iceseismic
    Just starting with the "load_japan-quakes" example ; I can get an output plot, but also receive 8 error messages as follows : any idea ?? : pygmt-session [ERROR]: GMT_COMPATIBILITY: Expects values from 6 to 6; reset to 6.
    Leonardo Uieda
    @leouieda
    Hi @iceseismic thanks for reporting. Wow, that's a new one :) Would you mind opening an issue here https://github.com/GenericMappingTools/pygmt/issues/new?template=bug_report.md ? Please fill out the template with some more info about your setup so we can try to figure it out.
    Sean
    @sean0921

    Hello. I'm wondering if there's any plan to add some require version info on requirement.txt requirement-dev.txt to let dependencies more clarify,

    because recently I'd like to trying package pygmt via PKGBUILD for makepkg tools in ArchLinux,
    https://github.com/sean0921/pygmt-aur.git

    as another python package built by makepkg, in build(), package() procedure, it seems ok,
    but when I try to use pygmt.test() in check() procedure,
    it encouters some error,
    related message: https://gist.github.com/sean0921/66eb9e45220ad20b3e1b0d355f67d199

    although it seems like that only Anaconda(Miniconda) Python is supported, I still curious that if it's possible to packaging it in the way of distribution package manager, let it more friendly and accessible for more users and developers. :)

    Leonardo Uieda
    @leouieda
    Hi @sean0921, thanks for trying this out! I was thinking of the AUR just yesterday. Right now, packaging would work because we don't really have a release yet and we still rely on the master branch of GMT. Once GMT 6 is released and we make a release of our own, then it would be great to have.
    Thanks for the reminder of specifying version numbers. They're loose right now so we can more easily test but once we're getting ready for a release we'll pin them more tightly. Would you mind opening an issue for that so we can keep track?
    Wei Ji
    @weiji14

    Hi! Very nice and useful initiative. I'm implementing laser altimetry simulations in python and happen to need the GMT grdtrack function to extract elevation data from a topography basemap. Is this function already implemented in pygmt or do you plan to implement it at some point? Thanks!

    Hi @steo85it, I'm using grdtrack myself and would be happy to implement it. Already have some code and will submit an issue and pull request which you're more than welcome to contribute to :)

    Wei Ji
    @weiji14
    Done! See Issue at #307 and PR at #308.
    At the moment the pygmt.grdtrack implementation requires you to load the table data into a pandas.DataFrame and the grid into an xarray.DataArray. Would it be better to have grdtrack work directly on files as well, or would this be the way to go? Thoughts?
    pedromarting
    @pedromarting
    Hello! A simple question. Can i use pygm with gmt6 (I read that is an obligated condition) and by the other hand use gmt5.4 without pygm (with the classic gmt script). The idea is to use an estable version of gmt and also try this incredible tool pygmt. Thanks!
    Eric Fielding
    @EJFielding
    Hello Pedro, Yes you should be able to install GMT 6 and GMT5 in separate directories on the same computer. You will need to change your environment variables to adjust the GMTHOME and other variables when you want to switch. I have both installed on my Mac.
    Leonardo Uieda
    @leouieda
    Hi Pedro, as Eric said, it is possible to do that. We're working on a conda package for the 6.0.0rc3 so that you could install in a separate environment without having to manipulate your PATH. We're having of trouble getting that to work still but I'll post here when we have it.
    titi-dev
    @titi-dev
    Hii,good afternoon I am titu from India. I need some suggestions.Actually I know gmt for plotting maps but it is based on the shell scripting which is quite tidious in nature.So i need a python based gmt tool for making the script easier for map plottings.So is this pygmt can help me ???
    pedromarting
    @pedromarting
    Cool @EJFielding ! Can you tell me how to do that thing about changing environment variables?(if is not a problem for you. I'm just a student of science). And obviously @leouieda I wait to that conda package too!! Thanks guys you're amaaazing.
    Chiara Marieni
    @ChiaraMarieni_twitter
    Hello, I have installed pygmt with conda on a new environment, but when I am trying to import pygmt in jupyter I get this error message: Error loading the GMT shared library 'gmt_w64.dll'. Can you help me?
    Leonardo Uieda
    @leouieda
    @titi-dev that is exactly what pygmt is designed to do. Keep in mind, though, that we're still designing the package and lot of GMT features aren't yet supported. But please feel free to give it a try and let us know if there is anything you find missing.
    @ChiaraMarieni_twitter are you using Windows? Make sure you have GMT installed as well. See https://www.pygmt.org/dev/install.html#finding-the-gmt-shared-library. PyGMT doesn't yet work well on Windows. We're having some issues and progress is slow since most developers are on Mac and Linux.
    titi-dev
    @titi-dev
    Thanks