Trouble with re-projecting a netcdf file

Added by H 5 months ago

This is my first post on the forum so bare with me.

I am trying to overlay a netcdf file from a titan weather radar.
First I extract the maximum dbz from the original nc file

gmt grdconvert nc20171230_000123.nc\?Max_DBZ -Gmaxdbz.nc

I then create a basemap of the area covered by the radar image

gmt pscoast -Rg -JE27.166700/-26.619332/1:20/20 -B15g15 -Di -Xc -Yc -Na -Glightgray -W0.25p -K > GMTTitan.ps

I re-project the maxdbz.nc file to the above coordinates (I think)

gmt grdedit maxdbz.nc -R -JE -Gproj_maxdbz.nc

And then try to plot the ncfile

gmt grdimage maxdbz.nc -R -JE -Q -O -K >> GMTTitan.ps

However plotting gives me the following error
grdimage: Error: Passing max ⇐ zmin prevents automatic CPT generation!

I am able to plot the maxdbz.nc file before I call grdedit with grdimage, but it's not what I want. The image should more or less fit into the plotted region
Inspecting the *maxdbz files with ncview only indicates that the variable named changed from Max_DBZ to z. The new projection in seems fine to me.

Regards
_

GMT Version 5.4.3

nc20171230_000123.nc (5.5 MB)

maxdbz.nc (181 KB)

proj_maxdbz.nc (182 KB)


Replies (5)

RE: Trouble with re-projecting a netcdf file - Added by Paul 5 months ago

Looks like your script is not using the proj_maxdvz.nc grid at all. Did you mean to use that in your grdimage command? If so that would be wrong since the proj* file would be in projected units, not degrees anymore. There is no need to proejct a grid before plotting it in grdimage; that is what the -JE option does. Please clarify that step for me. If on the other hand you are using the maxdbz.nc file directly then the error message has to do with finding the min/max values of your grid and scaling a CPT to fit it. Something goes wrong there. But clarify the question first.

RE: Trouble with re-projecting a netcdf file - Added by H 5 months ago

Hi Paul, sorry that was a typo on my part. It should be

gmt grdimage proj_maxdbz.nc -R -JE -Q -O -K >> GMTTitan.ps

Which yields the "grdimage: Error: Passing max ⇐ zmin prevents automatic CPT generation!" error.

I tried setting a custom cpt file with the range of the z value (just used gebco randomly). Now my script looks like this:

gmt grdconvert nc20171230_000123.nc\?Max_DBZ -Gmaxdbz.nc
gmt makecpt -Cgebco -T-31/18/3 -Z > radar.cpt
gmt pscoast -Rg -JE27.166700/-26.619332/1:20/20 -B15g15 -Di -Xc -Yc -Na -Glightgray -W0.25p -K > GMTTitan.ps
gmt grdedit maxdbz.nc -R -JE -Gproj_maxdbz.nc
gmt grdimage proj_maxdbz.nc -R -JE -Cradar.cpt -Q -O -K >> GMTTitan.ps

The error is gone, but the data is not overlayed on the map at all.
___________________________________________________

that would be wrong since the proj* file would be in projected units, not degrees anymore. There is no need to proejct a grid before plotting it in grdimage; that is what the -JE option does

If I understand you correctly I skip the grdedit call. Like this:

gmt grdconvert nc20171230_000123.nc\?Max_DBZ -Gmaxdbz.nc
gmt pscoast -Rg -JE27.166700/-26.619332/1:20/20 -B15g15 -Di -Xc -Yc -Na -Glightgray -W0.25p -K > GMTTitan.ps
gmt grdimage maxdbz.nc -R -JE -Cradar.cpt -Q -O -K >> GMTTitan.ps

However, the data is not plotted as expected (see example_1.ps). That's why I thought I need to "assign" a projection.

I am able to plot the data with the following command and this also illustrates what I want to overlay on the map (The -JE27.166700/-26.619332 I'm trying to assign in my script is the centre point).
Just to clarify, this plot looks the same no matter if I call proj_maxdbz.nc or the original maxdbz.nc

gmt grdimage proj_maxdbz.nc -JX25 -Xc -Yc -Q > Example_2.ps

Thank you

Example_1.ps (27.1 KB)

Example_2.ps (76.4 KB)

RE: Trouble with re-projecting a netcdf file - Added by Paul 5 months ago

Looking at the maxdbz.nc file it reports
maxdbz.nc: Title: Produced by grdconvert
maxdbz.nc: Command: grdconvert nc20171230_000123.nc?Max_DBZ -Gmaxdbz.nc
(old cmd) This MDV radar volume file was created by Dsr2Vol.
maxdbz.nc: Remark:
maxdbz.nc: Gridline node registration used [Cartesian grid]
maxdbz.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
maxdbz.nc: x_min: -299.625 x_max: 299.625 x_inc: 0.75 name: x0 [km] n_columns: 800
maxdbz.nc: y_min: -299.625 y_max: 299.625 y_inc: 0.75 name: y0 [km] n_rows: 800
maxdbz.nc: z_min: -40 z_max: 30.9381866455 name: Max DBZ [dBZ]

It clear is not degrees (latitude = -299?). I am not sure why GMT is not complaining about that. But I think you need to redo the prep of this data since the coordinates are wrong.

RE: Trouble with re-projecting a netcdf file - Added by H 5 months ago

"But I think you need to redo the prep of this data since the coordinates are wrong"

I kind of knew that would be the case, but I was hoping I could use GMT to fix it .
Thank you for your willingness to help so quickly.

Regards

RE: Trouble with re-projecting a netcdf file - Added by H 5 months ago

I ended up doing the following to get the plot I need

#!/bin/bash

gmt grdconvert nc20171230_000123.nc\?Max_DBZ -Gmaxdbz.nc
gmt pscoast -Rg -JE27.166700/-26.619322/1:20/20 -B15g15 -Df -Na -Xc -Yc -Na -Glightgray -W0.25p -K > GMTTitan.ps
gmt grdimage maxdbz.nc -JX29.8 -Xc -Yc -Q -O -K >> GMTTitan.ps

(1-5/5)