[ncl-talk] Possible to convert grib2 or netcdf files to grib1?
Colin Raymond
cr2630 at columbia.edu
Sat Mar 17 16:19:40 MDT 2018
Hi Mary,
Thank you so much for this invaluable help! I compiled cnvgrib successfully
and can't imagine having been able to do it otherwise. The key was those
sneaky changes that need to be made for FFLAGS and CFLAGS in g2lib and
w3lib respectively. For anyone else who might have this problem on a Mac,
there were a couple other little things that I had to do to point the
compilers in the right direction, such as copying libpng.3.dylib from
/opt/X11/lib to /usr/local/lib and adding a few directories to my
~/.bash_profile so everything played nicely together.
The step-by-step instructions were great and I plan to use this as a
reference for future times that I get stuck on an installation.
Best regards,
Colin
On Sat, Mar 17, 2018 at 2:53 PM, Mary Haley <haley at ucar.edu> wrote:
> Hi Colin,
>
> I was able to get the cnvgrib program to compile, but it did require some
> arm wrestling. Here are the steps I took:
>
> [1] Download the w3lib-2.0.6.tar, g2lib-3.1.0.tar,
>
> jasper-1.900.1
> .zip, libpng-1.2.34.tar,
> and cnvgrib-3.1.0.tar files from:
>
> http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2/
>
> I recommend putting them all in a common root directory. Extract the tar
> files using "tar -xvf *file*.tar", and the zip file using "unzip *file*.zip".
> This should give you directories:
>
> cnvgrib-3.1.0/
> g2lib-3.1.0/
> jasper-1.900.1/
> libpng-1.2.34/
> w3lib-2.0.6/
>
> You need to compile the w3lib, libpng, jasper, and g2lib packages in order
> to get the libraries needed to compile cnvgrib. If you already have these
> libraries, then you can skip steps for building these.
>
> *[2] libpng*
>
> Cd to libpng-1.2.34 and type:
>
> ./configure
> make
>
> This should work without any modifications, especially if you have the GNU
> compilers gcc and gfortran on your system. You should end up with a
> .lib/libpng.a library.
>
> *[3] jasper*
>
> Just as with the libpng directory, cd to jasper-1.900.1 and type:
>
> ./configure
> make
>
> This should produce a src/libjasper/.libs/libjasper.a library.
>
> *[4] g2clib*
>
> Cd to g2lib-3.1.0 and edit the makefile (make a copy of it first).
>
>
> You first need to modify the INCDIR line to point to your libpng and
> jasper directories. Since I had put mine all in the same root directory, my
> INCDIR line looked like this:
>
> INCDIR
>
> =
>
> -I../jasper-1.900.1/src/libjasper/include -I../libpng-1.2.34
>
> The makefile is set up to use g95 as the Fortran 90 compiler which I don't
> have, so I modified it to use gfortran. The makefile has a section for
> gfortran that you just need to uncomment, and then you need to comment out
> the g95 section:
>
> #--------------------------------------
>
> # The following was used for GFORTRAN on LINUX
>
> # ----- used with 64-bit machine ---
>
> #
>
> DEFS=-DLINUX
> FC=gfortran
> CC=cc
> FFLAGS=-O3 -I $(MODDIR) -fno-range-check
> CFLAGS=-O3 $(DEFS) $(INCDIR) -D__64BIT__
> CPP=cpp -P -C
> MODDIR=.
>
>
> #--------------------------------------
>
> # The following was used for G95 on LINUX
>
> # ----- used with 32-bit machine ---
>
> #
>
> # DEFS=-DLINUXG95
>
> # FC=g95
>
> # CC=cc
>
> # CPP=cpp -P -C
>
> # MODDIR=.
>
> # CFLAGS=-O3 $(DEFS) $(INCDIR)
>
> # FFLAGS=-O3 -g -I $(MODDIR)
>
> Note that I had to add -fno-range-check to the FFLAGS line, because
> otherwise I got this error:
>
> Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) at (1).
> This check can be disabled with the option ‘-fno-range-check’
>
> Type "make" and it should create "libg2.a". If it doesn't, and you get an
> error about intmath.mod, then you may need to type something like this:
>
> gfortran -c intmath.f
>
> and then type make again.
>
>
> *[5] w3lib*
>
> Cd to w3lib-2.0.6 and edit the Makefile in that directory (make a backup
> copy of it first).
>
> Again, the Makefile is set up to use the "g95" Fortran compiler, so I
> uncommented the section for the gfortran compiler and commented the g95
> section:
>
> # OPTIONS FOR GFORTRAN
>
> F77 = gfortran
> FFLAGS = -g -O
> CFLAGS = -O -DLINUX -I/usr/include/malloc
> CC = cc
> ARFLAGS =
>
> # F77 = g95
>
> # FFLAGS = -g -O
>
> # CFLAGS = -O -DLINUX
>
> # CC = cc
>
> # ARFLAGS =
>
> Note that I had to add a "-I/usr/include/malloc", because otherwise one of
> the files complained that it couldn't find "malloc.h".
>
> Type "make" and this should produce a libw3.a library.
>
> *[6] cnvgrib*
>
> Assuming steps 2-5 were successful, you should now be able to build
> cnvgrib. Edit the makefile and change "FC" to be gfortran, if this is the
> compiler you're using. Otherwise change it to the desired compiler.
>
> Then, you will need to change these lines:
>
> INC = -I /pub/share/ncoops/g2lib-1.2.2
>
> LIBS = -L/pub/share/ncoops/g2lib-1.2.2 -lg2\
> -L/pub/share/ncoops/w3lib-2.0 -lw3\
> -L/pub/share/ncoops/jasper-1.900.1/src/libjasper/.libs -ljasper
> -lpng -lz
>
> to point to your own versions of these packages. If you built everything
> as I described above, then these settings should work:
>
> INC = -I ../g2lib-3.1.0
>
> LIBS = -L../g2lib-3.1.0 -lg2\
> -L../w3lib-2.0.6 -lw3\
> -L../libpng-1.2.34/.libs \
> -L../jasper-1.900.1/src/libjasper/.libs -ljasper -lpng -lz
>
> Type "make" and you should have a cnvgrib file. :-)
>
> --Mary
>
>
>
>
>
>
>
>
>
> On Fri, Mar 16, 2018 at 4:54 PM, Colin Raymond <cr2630 at columbia.edu>
> wrote:
>
>> Hi Mary & Guilherme,
>>
>> Thanks for the replies. When I run 'make' in my cnvgrid-3.1.0 directory I
>> get the following error:
>>
>> In file pds2pdt.f:50
>>
>>
>> use params
>>
>> 1
>>
>> Fatal Error: Can't open module file 'params.mod' at (1) for reading: No
>> such file or directory
>>
>>
>>
>> I think the ultimate problem lies with my not being able to install
>> g2lib; when I attempt to do so, I get the error:
>>
>> m2c -o g2grids.o g2grids.mod
>>
>> make: m2c: No such file or directory
>>
>>
>> and inserting the line %.o : %.mod results in a different error:
>>
>>
>> make: *** No rule to make target `libg2.a(g2grids.o)', needed by
>> `libg2.a'. Stop.
>>
>>
>> The problem is probably simple, but I've yet to make any headway on these
>> errors.
>>
>>
>>
>> Regarding wgrib2, I found examples and documentation of using it to
>> convert grib1 to grib2, but not vice versa. If you could kindly provide
>> guidance on how the conversion to grib1 could be done using wgrib2 (if
>> possible), I'd greatly appreciate it.
>>
>>
>> Best regards,
>>
>> Colin
>>
>>
>>
>>
>>
>>
>> On Fri, Mar 16, 2018 at 5:58 AM, <ncl-talk-request at ucar.edu> wrote:
>>
>>> Send ncl-talk mailing list submissions to
>>> ncl-talk at ucar.edu
>>>
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> or, via email, send a message with subject or body 'help' to
>>> ncl-talk-request at ucar.edu
>>>
>>> You can reach the person managing the list at
>>> ncl-talk-owner at ucar.edu
>>>
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of ncl-talk digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>> 1. Re: Missing values after ESMF regridding (Mary Haley)
>>> 2. Re: Plotting netCDF (Dave Allured - NOAA Affiliate)
>>> 3. Unable to set explicit levels on contour plot
>>> (Nicholas Thomas Luchetti)
>>> 4. Re: Unable to set explicit levels on contour plot (Adam Phillips)
>>> 5. Re: Possible to convert grib2 or netcdf files to grib1?
>>> (Mary Haley)
>>> 6. Re: Possible to convert grib2 or netcdf files to grib1?
>>> (Guilherme Martins)
>>> 7. Regridding Moving Nest WRF outputs (Lara Quiti?n Hern?ndez)
>>>
>>>
>>> ----------------------------------------------------------------------
>>>
>>> Message: 1
>>> Date: Thu, 15 Mar 2018 13:54:35 -0600
>>> From: Mary Haley <haley at ucar.edu>
>>> To: Bian Qingyun <bianqy at tea.ac.cn>
>>> Cc: Ncl-talk <ncl-talk at ucar.edu>
>>> Subject: Re: [ncl-talk] Missing values after ESMF regridding
>>> Message-ID:
>>> <CACNN_CK6jVgR4S=Z=d7fwr4MGdw5QUPhbQ_Ho3-yi=Nc6=WJEQ at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Hi Bian,
>>>
>>> I'm looking into this.
>>>
>>> Meanwhile, I see that your original data goes from -180 to 180, but the
>>> lower left corner and upper right corner of the destination grid was set
>>> to:
>>>
>>> Opt at DstLLCorner = (/ 0.25d, 0.25d/)
>>> Opt at DstURCorner = (/89.75d, 179.75d/)
>>>
>>> This is restricting your data in the longitude direction to go from 0.25
>>> and 179.75. Perhaps you meant for this to be:
>>>
>>> Opt at DstLLCorner = (/ 0.25d, -180.00d/)
>>> Opt at DstURCorner = (/89.75d, 179.75d/)
>>>
>>> However, this still doesn't fix the issue, so I'm looking into it
>>> further.
>>> I'm wondering if this is a missing value issue, because I noticed that
>>> your
>>> lat/lon has some missing values in it.
>>>
>>> --Mary
>>>
>>>
>>>
>>> On Thu, Mar 15, 2018 at 2:08 AM, Bian Qingyun <bianqy at tea.ac.cn> wrote:
>>>
>>> >
>>> >
>>> > Hello,
>>> >
>>> > I'm regridding AMSR-E L3 daily snow following the examples on NCL
>>> website
>>> > http://www.ncl.ucar.edu/Applications/Scripts/ESMF_regrid_13.ncl and
>>> hdf
>>> > website http://hdfeos.org/zoo/index_openNSIDC_Examples.php#AMSR_E.
>>> >
>>> > All is fine,but there are missing values along 90?E and 90?W after
>>> > regridding while there are no missing values in original data along and
>>> > near 90?E and 90?W ?
>>> >
>>> > Below is my script. I also attached the AMSR-E data file in case.
>>> >
>>> > ----------------------
>>> >
>>> > ----------------------
>>> >
>>> > load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
>>> >
>>> > begin
>>> > ;-----read data
>>> > srcFileName = "AMSR_E_L3_DailySnow_V09_20100311.hdf"
>>> > ; Source file
>>> > eos_file = addfile(srcFileName + ".he2","r")
>>> > lon2d = eos_file->GridLon_Northern_Hemisphere
>>> > lat2d = eos_file->GridLat_Northern_Hemisphere
>>> > ; Process NAN (1e51) fillValue for LAMAZ geolocation.
>>> > lon2d=where(lon2d .gt. 1000, -999.0, lon2d)
>>> > lat2d=where(lat2d .gt. 1000, -999.0, lat2d)
>>> > lon2d at _FillValue = -999.0
>>> > lat2d at _FillValue = -999.0
>>> >
>>> >
>>> > hdf_file = addfile(srcFileName, "r")
>>> > ; Read the dataset.
>>> > hdf_data = hdf_file->SWE_NorthernDaily
>>> >
>>> > ; Filter out invalid range values.
>>> > ; See "Table 2. Pixel Values ofr the SWE Feids" from [2].
>>> > hdf_data = where(hdf_data .gt. 240, hdf_data at _FillValue, hdf_data)
>>> >
>>> > ; Prepare data for plotting by converting type.
>>> > swe2d = tofloat(hdf_data)
>>> > swe2d at _FillValue = tofloat(hdf_data at _FillValue)
>>> >
>>> > ; Multiply by two according to data spec [2].
>>> > swe2d = 2 * swe2d
>>> >
>>> > ; You can get the description of data set from the data spec [2].
>>> > swe2d at long_name = "Northern Hemisphere 5-day Snow Water Equivalent
>>> > ~C~ (" + hdf_data at hdf_name + ")"
>>> > swe2d at units = "mm"
>>> > ; Associate data with lat/lon.
>>> > swe2d at lon2d = lon2d
>>> > swe2d at lat2d = lat2d
>>> >
>>> > ;-----ESMF regridding
>>> > Opt = True ; Options for regridding
>>> >
>>> > Opt at SrcFileName = "EASE_SCRIP.nc" ; Output files
>>> > Opt at DstFileName = "NH_SCRIP.nc"
>>> > Opt at WgtFileName = "EASE_2_NH_patch.nc"
>>> > Opt at ForceOverwrite = True
>>> > Opt at SrcMask2D = where(ismissing(lat2d),0,1)
>>> > Opt at SrcGridLat = lat2d
>>> > Opt at SrcGridLon = lon2d
>>> >
>>> > Opt at DstGridType = "0.25deg" ; Destination grid
>>> > Opt at DstTitle = "Northern Hemisphere 0.25 resolution"
>>> > Opt at DstLLCorner = (/ 0.25d, 0.25d/)
>>> > Opt at DstURCorner = (/89.75d, 179.75d/)
>>> >
>>> > Opt at InterpMethod = "bilinear" ; Careful! Patch method
>>> takes a
>>> > long time
>>> >
>>> > Opt at Debug = True
>>> >
>>> > swe_regrid = ESMF_regrid(swe2d,Opt) ; Regrid swe
>>> > printVarSummary(swe_regrid)
>>> >
>>> > ;-----------------------------------------------------------
>>> -----------
>>> > ; Plotting section
>>> > ;-----------------------------------------------------------
>>> -----------
>>> > wks = gsn_open_wks("x11","ESMF_regrid") ; send graphics to PNG
>>> > file
>>> >
>>> > res = True ; Plot mods desired.
>>> > res at gsnMaximize = True ; Maximize plot
>>> >
>>> > res at gsnDraw = False
>>> > res at gsnFrame = False
>>> >
>>> > res at cnFillOn = True ; color plot desired
>>> > res at cnFillPalette = "amwg" ; set color map
>>> > res at cnLinesOn = False ; turn off contour
>>> lines
>>> > res at cnLineLabelsOn = False ; turn off contour
>>> labels
>>> > res at cnFillMode = "RasterFill" ; turn raster on
>>> >
>>> > res at cnLevelSelectionMode= "ExplicitLevels" ; set explicit contour
>>> > levels
>>> > res at cnLevels = (/-300,-250,-200,-150,-100, \
>>> > 0,1,5,10,25,100,200,300,400/)
>>> >
>>> > res at lbLabelBarOn = False ; turn on in panel
>>> >
>>> > res at trGridType = "TriangularMesh" ; allow missing
>>> > coordinates
>>> >
>>> >
>>> > res at gsnPolar = "NH" ; specify the
>>> hemisphere
>>> > res at mpMinLatF = 35
>>> >
>>> > ;---Plot original data.
>>> > res at gsnAddCyclic = False
>>> > res at sfXArray = lon2d
>>> > res at sfYArray = lat2d
>>> > res at tiMainString = "Original EASE grid (" +
>>> > str_join(dimsizes(lat2d),",") + ")"
>>> > res at trGridType = "TriangularMesh"
>>> > res at cnFillMode = "RasterFill"
>>> >
>>> > plot_orig = gsn_csm_contour_map_polar(wks,swe2d,res)
>>> >
>>> > delete(res at sfXArray)
>>> > delete(res at sfYArray)
>>> >
>>> > ;---Plot regridded data.
>>> > res at gsnAddCyclic = True
>>> >
>>> > dims = tostring(dimsizes(swe_regrid))
>>> > res at tiMainString = "Regridded to 0.25 degree grid (" + \
>>> > str_join(dims," x ") + ")"
>>> >
>>> > plot_regrid = gsn_csm_contour_map_polar(wks,swe_regrid,res)
>>> >
>>> > ;---Compare the plots in a panel
>>> > pres = True
>>> > pres at gsnMaximize = True
>>> > pres at gsnPanelLabelBar = True
>>> > pres at lbLabelFontHeightF = 0.01
>>> > pres at pmLabelBarWidthF = 0.8
>>> >
>>> > gsn_panel(wks,(/plot_orig,plot_regrid/),(/1,2/),pres)
>>> > end
>>> >
>>> > ---------------------------
>>> >
>>> > ---------------------------
>>> >
>>> > Any suggestions are appreciated! Thank you!
>>> >
>>> > Best,
>>> >
>>> > Qingyun
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> > ncl-talk mailing list
>>> > ncl-talk at ucar.edu
>>> > List instructions, subscriber options, unsubscribe:
>>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >
>>> >
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/4e73d5fc/attachment-0001.html>
>>>
>>> ------------------------------
>>>
>>> Message: 2
>>> Date: Thu, 15 Mar 2018 14:09:27 -0600
>>> From: Dave Allured - NOAA Affiliate <dave.allured at noaa.gov>
>>> To: "Smith, Stuart" <smit1770 at purdue.edu>
>>> Cc: Ncl-talk <ncl-talk at ucar.edu>
>>> Subject: Re: [ncl-talk] Plotting netCDF
>>> Message-ID:
>>> <CALqwTFNC1uoYD7t1g71g-LLqCBWadFAot5H6NkSLWe3dUNjz3A at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Stuart,
>>>
>>> When reading the whole array, subscripts are not needed. Just use whole
>>> array syntax:
>>>
>>> x = f->ppt
>>>
>>> You did not fix the mismatched _FillVallue problem that I mentioned
>>> before. You will need to either fix the file, or else add this kludge to
>>> make NCL properly recognize the missing values after they are read in:
>>>
>>> x at _FillValue := todouble (x at missing_value)
>>>
>>> With that fix, it looks like your ppt.nc data file is pre-masked for a
>>> predetermined spatial area. To calculate a simple spatial average time
>>> series for all grid points within that predetermined area, just use a
>>> simple unweighted array averaging function:
>>>
>>> dim_select = (/ 1, 2 /) ; select lat and lon dims to average
>>> over
>>> spatial_aves = dim_avg_n_Wrap (x, dim_select) ; makes a 1-D time
>>> series
>>>
>>> Please read the function documentation for dim_avg_n and dim_avg_n_Wrap,
>>> for more details.
>>>
>>> If you need latitude weighting, or you need to select a smaller spatial
>>> area within the existing domain, then more code will be needed.
>>>
>>> --Dave
>>>
>>>
>>> On Wed, Mar 14, 2018 at 8:06 AM, Smith, Stuart <smit1770 at purdue.edu>
>>> wrote:
>>>
>>> > Dave,
>>> >
>>> >
>>> >
>>> > Thanks for the feedback. I was able to get more data. The runoff data
>>> > didn?t look useful, so I have attached another variable (precipitation)
>>> > which had more data over the spatial area, but still missing data
>>> (-9999).
>>> > The variables are:
>>> >
>>> >
>>> >
>>> > 0) PPT=Precipitation
>>> >
>>> > 1) T = Time
>>> >
>>> > 2) X= Longitude
>>> >
>>> > 3) Y = Latitude
>>> >
>>> >
>>> >
>>> > In order to calculate spatial averages over time would I read in all
>>> > dimensions, similar to what you have described below and calculate the
>>> > average using a function? Thank you for your time.
>>> >
>>> >
>>> >
>>> > x = f->runoff(:,:,:) ; x will be read as a 3-D array
>>> >
>>> >
>>> >
>>> > Regards,
>>> >
>>> >
>>> >
>>> > -Stuart
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > *From:* Dave Allured - NOAA Affiliate [mailto:dave.allured at noaa.gov]
>>> > *Sent:* Tuesday, March 13, 2018 5:12 PM
>>> > *To:* Smith, Stuart <smit1770 at purdue.edu>
>>> > *Cc:* Ncl-talk <ncl-talk at ucar.edu>
>>> > *Subject:* Re: [ncl-talk] Plotting netCDF
>>> >
>>> >
>>> >
>>> > Stuart,
>>> >
>>> >
>>> >
>>> > That is a strange Netcdf file. It is a time series of 45 x 29 grids,
>>> but
>>> > all grid points are missing values, except for one corner point at
>>> > (*,0,0). You can extract the corner point as a 1-D time series, and
>>> make a
>>> > line plot and other 1-D analysis.
>>> >
>>> >
>>> >
>>> > x = f->runoff(:,0,0) ; x will be read as a 1-D array
>>> >
>>> >
>>> >
>>> > However, you requested how to calculate spatial averages. That does
>>> not
>>> > make sense if you do not have valid data over multiple grid points. So
>>> > either you can just do 1-D plots and analysis, or you need to go back
>>> to
>>> > your data source and get a file with valid data over your desired
>>> spatial
>>> > area.
>>> >
>>> >
>>> >
>>> > If you get another data file, also please ask the provider to make the
>>> > _FillValue match the array data type, which is "double" in this case.
>>> >
>>> >
>>> >
>>> > --Dave
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > On Tue, Mar 13, 2018 at 2:20 PM, Smith, Stuart <smit1770 at purdue.edu>
>>> > wrote:
>>> >
>>> > Good afternoon,
>>> >
>>> >
>>> >
>>> > I received a netCDF file that has a format I am unfamiliar with and
>>> wanted
>>> > guidance on calculating spatial averages over time. Attached is a copy
>>> of
>>> > the .nc file. The variables are:
>>> >
>>> > 0) Runoff
>>> >
>>> > 1) T=Time
>>> >
>>> > 2) X= Longitude
>>> >
>>> > 3) Y = Latitude
>>> >
>>> > When defining variables for runoff (ex. Var = fi->runoff ), the output
>>> > format is the following:
>>> >
>>> > (0,0,0) 0
>>> >
>>> > (0,0,1) -9999
>>> >
>>> > (0,0,2) -9999
>>> >
>>> > (0,0,3) -9999
>>> >
>>> > (0,0,4) -9999
>>> >
>>> > ??..
>>> >
>>> > (1,0,0) 0
>>> >
>>> > (1,0,1) -9999
>>> >
>>> > (1,0,2) -9999
>>> >
>>> >
>>> >
>>> > The next value will not appear until (1,0,0). I wanted to ask how I
>>> would
>>> > plot such data, and calculate averages over the area with the given
>>> > format? Thank you for your time.
>>> >
>>> >
>>> >
>>> > Regards,
>>> >
>>> >
>>> >
>>> > -Stuart
>>> >
>>> >
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/625a2408/attachment-0001.html>
>>>
>>> ------------------------------
>>>
>>> Message: 3
>>> Date: Thu, 15 Mar 2018 15:16:49 -0600
>>> From: Nicholas Thomas Luchetti <Nicholas.Luchetti at colorado.edu>
>>> To: ncl-talk <ncl-talk at ucar.edu>
>>> Subject: [ncl-talk] Unable to set explicit levels on contour plot
>>> Message-ID:
>>> <CANDmd5LYvsF1Vf6e_wSDNGfNbvG967SkwBKpheYhWLbqeRBivA at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Hi all,
>>>
>>> I am trying to set explicit contour levels on a vertical cross-section
>>> plot
>>> however with no luck....
>>>
>>> I've tried both "ExplicitLevels" and "ManualLevels" settings but neither
>>> seem to work.
>>>
>>> I've looked at all sorts of examples online but can't seem to see why
>>> mine
>>> won't work
>>>
>>> I've attached my script. As well as two plots from 2 different WRF
>>> runs...
>>> I want to be able to compare these, but if I can't set the scale the same
>>> then it's difficult to compare....
>>>
>>> Does anyone have any idea as to why I can not set these levels?
>>>
>>> Thanks!
>>>
>>> Nick Luchetti
>>>
>>> --
>>> Nicholas Luchetti
>>> Graduate Student
>>> Department of Atmospheric and Oceanic Sciences (ATOC)
>>> CU Boulder
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/b5a5b41b/attachment-0001.html>
>>> -------------- next part --------------
>>>
>>> ;----------------------------------------------------------------------
>>> ; WRF_cn_4.ncl
>>> ;
>>> ; Concepts illustrated:
>>> ; - Plotting WRF data
>>> ; - Plotting a cross section
>>> ;----------------------------------------------------------------------
>>> ; WRF: time-z cross section.
>>> ;----------------------------------------------------------------------
>>> ; These files are loaded by default in NCL V6.2.0 and newer
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
>>>
>>> begin
>>> ;---Open file; substitute your own WRF output file here
>>> f = addfile ("/Users/nicholasluchetti/Buil
>>> d_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_control.nc","r")
>>> ; f = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_qua
>>> rter_ss/wrfout_d01_simulation_1.nc","r")
>>>
>>> ; f = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_qua
>>> rter_ss/wrfout_d01_simulation_4.nc","r")
>>> ; f = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_qua
>>> rter_ss/wrfout_d01_simulation_3.nc","r")
>>> ; f = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_qua
>>> rter_ss/wrfout_d01_simulation_2.nc","r")
>>>
>>> ;
>>> ; Read character variable Times
>>> ; Convert to units of "hours since" for plotting purposes
>>> ;
>>> times = f->Times
>>> Time = wrf_times_c(f->Times, 0) ; convert to "hours since"
>>> print(Time)
>>> ;
>>> ; Read W(bottom_top_stag,west_east) at lat
>>> ; index 15, lon index nlon.
>>> ; Read associated levels and longitudes
>>> ;
>>> nlat = 85
>>> nlon = 120
>>> w = f->W(:,:,nlat,nlon) ; W(Time,bottom_top_stag)
>>> znw = f->ZNW(0,:) ; znw(bottom_top_stag)
>>>
>>> print("test3")
>>>
>>> printVarSummary(w)
>>> w&Time := Time
>>> printVarSummary(w)
>>> print(w&Time)
>>>
>>> print("test4")
>>>
>>> ;---Use simple array syntax [like f90] to change units
>>> w = w ; for demo change units
>>> w at units = "m/s"
>>>
>>> printVarSummary(w)
>>> printMinMax(w,0)
>>>
>>> ;---Add/change meta data to conform to netCDF convention standards
>>> w!0 = "Time"
>>> w&Time = Time
>>> w!1 = "lev" ; name dimensions
>>> w&lev = znw ; assign values to named
>>> dimensions
>>>
>>>
>>> ;---For plot purposes only, read the specific lat/lon point
>>> lat = f->XLAT(0,nlat,nlon)
>>> lon = f->XLONG(0,nlat,nlon)
>>> ;
>>> ; create plots
>>> ; (1) A "BlWhRe" is often selected when plus/minus are of interest
>>> ; (2) The "symMinMaxPlt" procedure determines contour limits
>>> ; that are symmetric.
>>> ; (3) Use the "sprintf" function to format the title
>>> ; (4) Because the rightmost dimension will become the "x" axis
>>> ; use NCL's "dimension reordering" to reshape
>>> ;
>>> ; wks = gsn_open_wks("pdf","plt_vv_vertical_sim2.pdf")
>>> wks = gsn_open_wks("pdf","plt_vv_vertical_control.pdf")
>>> ; wks = gsn_open_wks("pdf","plt_vv_vertical_sim3.pdf")
>>> ; wks = gsn_open_wks("pdf","plt_vv_vertical_sim1.pdf")
>>> ; wks = gsn_open_wks("pdf","plt_vv_vertical_sim4.pdf")
>>> gsn_define_colormap(wks,"MPL_PRGn")
>>>
>>>
>>> res = True ; plot mods desired
>>> ;res at gsnMaximize = True ; maximize plot size
>>> res at cnLevelSelectionMode = "ManualLevels" ; manually set the
>>> contour levels with the following 3 resources
>>> res at cnMinLevelValF = -10. ; set the minimum
>>> contour level
>>> res at cnMaxLevelValF = 10. ; set the maximum
>>> contour level
>>> res at cnLevelSpacingF = 1. ; set the interval
>>> between contours
>>>
>>> ;res at cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour
>>> levels
>>> ;res at cnLevels = (/ -12, -10.,-8.,-6.,-4.,-2.,-1.,1.,2.,4.,6.,8.,10.,12./)
>>> ; set levels
>>>
>>> res at cnFillOn =True
>>> res at cnLinesOn = False ; turn off contour lines
>>> res at lbOrientation = "vertical" ; vertical label bar
>>>
>>> res at trYReverse = True ; reverse y axis
>>> res at tiXAxisString = Time at units ; label bottom axis with
>>> units attribute
>>> symMinMaxPlt(w, 14, False, res) ; contributed.ncl
>>>
>>> res at tiMainString = sprintf("%4.2f", nlat)+ " " \
>>> + sprintf("%4.2f", fabs(nlon))
>>> print("test")
>>> plot = gsn_csm_contour(wks,w(lev|:,Time|:),res)
>>> end
>>> -------------- next part --------------
>>> A non-text attachment was scrubbed...
>>> Name: plt_vv_vertical_control.pdf
>>> Type: application/pdf
>>> Size: 63930 bytes
>>> Desc: not available
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/b5a5b41b/attachment-0002.pdf>
>>> -------------- next part --------------
>>> A non-text attachment was scrubbed...
>>> Name: plt_vv_vertical_sim1.pdf
>>> Type: application/pdf
>>> Size: 62514 bytes
>>> Desc: not available
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/b5a5b41b/attachment-0003.pdf>
>>>
>>> ------------------------------
>>>
>>> Message: 4
>>> Date: Thu, 15 Mar 2018 15:52:14 -0600
>>> From: Adam Phillips <asphilli at ucar.edu>
>>> To: Nicholas.Luchetti at colorado.edu
>>> Cc: ncl-talk <ncl-talk at ucar.edu>
>>> Subject: Re: [ncl-talk] Unable to set explicit levels on contour plot
>>> Message-ID:
>>> <CACvWuqCSoOyJLvkCHCHHkGfa6yPQdVeJfQYH9bMmQjXbF2xohg at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Hi Nick,
>>> I think what is happening is that symMinMaxPlt is overruling your
>>> previous
>>> settings of cnLevels. Try uncommenting out these lines:
>>> res at cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour
>>> levels
>>> res at cnLevels = (/ -12,
>>> -10.,-8.,-6.,-4.,-2.,-1.,1.,2.,4.,6.,8.,10.,12./) ; set levels
>>> and then comment out the symMinMaxPlt line:
>>> ;symMinMaxPlt(w, 14, False, res)
>>>
>>> If that doesn't fix it let ncl-talk know..
>>> Adam
>>>
>>> On Thu, Mar 15, 2018 at 3:16 PM, Nicholas Thomas Luchetti <
>>> Nicholas.Luchetti at colorado.edu> wrote:
>>>
>>> > Hi all,
>>> >
>>> > I am trying to set explicit contour levels on a vertical cross-section
>>> > plot however with no luck....
>>> >
>>> > I've tried both "ExplicitLevels" and "ManualLevels" settings but
>>> neither
>>> > seem to work.
>>> >
>>> > I've looked at all sorts of examples online but can't seem to see why
>>> mine
>>> > won't work
>>> >
>>> > I've attached my script. As well as two plots from 2 different WRF
>>> > runs... I want to be able to compare these, but if I can't set the
>>> scale
>>> > the same then it's difficult to compare....
>>> >
>>> > Does anyone have any idea as to why I can not set these levels?
>>> >
>>> > Thanks!
>>> >
>>> > Nick Luchetti
>>> >
>>> > --
>>> > Nicholas Luchetti
>>> > Graduate Student
>>> > Department of Atmospheric and Oceanic Sciences (ATOC)
>>> > CU Boulder
>>> >
>>> >
>>> > _______________________________________________
>>> > ncl-talk mailing list
>>> > ncl-talk at ucar.edu
>>> > List instructions, subscriber options, unsubscribe:
>>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >
>>> >
>>>
>>>
>>> --
>>> Adam Phillips
>>> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
>>> www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
>>>
>>> <http://www.cgd.ucar.edu/staff/asphilli>
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/bbc880fa/attachment-0001.html>
>>>
>>> ------------------------------
>>>
>>> Message: 5
>>> Date: Thu, 15 Mar 2018 18:07:33 -0600
>>> From: Mary Haley <haley at ucar.edu>
>>> To: Colin Raymond <csr859 at gmail.com>
>>> Cc: Ncl-talk <ncl-talk at ucar.edu>
>>> Subject: Re: [ncl-talk] Possible to convert grib2 or netcdf files to
>>> grib1?
>>> Message-ID:
>>> <CACNN_C+t40fAzx-2dimV0QJBFpi2CVfLxLcmQ-eKLrcEHa=4kQ at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Hi Colin,
>>>
>>> NCL cannot write GRIB data, so I'm afraid we can't help you there.
>>>
>>> But we might be able to help with the cnvgrib compilation issues.
>>> Usually
>>> these smaller programs aren't too difficult to compile. Are you getting
>>> some kind of error from it?
>>>
>>> --Mary
>>>
>>>
>>> On Tue, Mar 13, 2018 at 4:54 PM, Colin Raymond <csr859 at gmail.com> wrote:
>>>
>>> > Hi all,
>>> >
>>> > Does anyone know of a procedure or combination of procedures that can
>>> > convert geospatial data *to* grib1 format using NCL 6.4.0? I'm working
>>> on a
>>> > Mac (OS 10.12.6, Darwin Kernel 16.7.0) and consequently I have been
>>> unable
>>> > to compile cnvgrib, which would be the only alternative that I know of
>>> for
>>> > this conversion.
>>> >
>>> >
>>> > Thanks,
>>> >
>>> > Colin Raymond
>>> >
>>> >
>>> > _______________________________________________
>>> > ncl-talk mailing list
>>> > ncl-talk at ucar.edu
>>> > List instructions, subscriber options, unsubscribe:
>>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >
>>> >
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0315/f16f2f23/attachment-0001.html>
>>>
>>> ------------------------------
>>>
>>> Message: 6
>>> Date: Fri, 16 Mar 2018 00:30:24 +0000
>>> From: Guilherme Martins <jgmsantos at gmail.com>
>>> To: Mary Haley <haley at ucar.edu>
>>> Cc: Ncl-talk <ncl-talk at ucar.edu>, Colin Raymond <csr859 at gmail.com>
>>> Subject: Re: [ncl-talk] Possible to convert grib2 or netcdf files to
>>> grib1?
>>> Message-ID:
>>> <CAH+t_hPttX8uR0xYm5=fNCrLG6kLHFsT4OeXAPZToSQayYdj9w at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> You can use wgrib2.
>>>
>>> http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/
>>>
>>>
>>>
>>> Em qui, 15 de mar de 2018 ?s 21:07, Mary Haley <haley at ucar.edu>
>>> escreveu:
>>>
>>> > Hi Colin,
>>> >
>>> > NCL cannot write GRIB data, so I'm afraid we can't help you there.
>>> >
>>> > But we might be able to help with the cnvgrib compilation issues.
>>> Usually
>>> > these smaller programs aren't too difficult to compile. Are you
>>> getting
>>> > some kind of error from it?
>>> >
>>> > --Mary
>>> >
>>> >
>>> > On Tue, Mar 13, 2018 at 4:54 PM, Colin Raymond <csr859 at gmail.com>
>>> wrote:
>>> >
>>> >> Hi all,
>>> >>
>>> >> Does anyone know of a procedure or combination of procedures that can
>>> >> convert geospatial data *to* grib1 format using NCL 6.4.0? I'm
>>> working on a
>>> >> Mac (OS 10.12.6, Darwin Kernel 16.7.0) and consequently I have been
>>> unable
>>> >> to compile cnvgrib, which would be the only alternative that I know
>>> of for
>>> >> this conversion.
>>> >>
>>> >>
>>> >> Thanks,
>>> >>
>>> >> Colin Raymond
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> ncl-talk mailing list
>>> >> ncl-talk at ucar.edu
>>> >> List instructions, subscriber options, unsubscribe:
>>> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >>
>>> >>
>>> > _______________________________________________
>>> > ncl-talk mailing list
>>> > ncl-talk at ucar.edu
>>> > List instructions, subscriber options, unsubscribe:
>>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >
>>> --
>>>
>>> <http://www.inpe.br/queimadas/>
>>> Guilherme Martins
>>> Meteorologista
>>>
>>> Rodovia Presidente Dutra, km 40 - 12630000
>>> Cachoeira Paulista, SP - Brasil
>>> +55 12 3186-9205 +55 12 98111-4292
>>> jgmsantos at gmail.com
>>> http://www.inpe.br/queimadas
>>> [image: skype] guilherme.martins.
>>> https://www.researchgate.net/profile/Guilherme_Martins6
>>> [image: Curr?culo Lattes] http://lattes.cnpq.br/5997657584785803
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0316/af705455/attachment-0001.html>
>>>
>>> ------------------------------
>>>
>>> Message: 7
>>> Date: Fri, 16 Mar 2018 10:58:04 +0100
>>> From: Lara Quiti?n Hern?ndez <laraquitianhernandez at gmail.com>
>>> To: ncl-talk at ucar.edu
>>> Subject: [ncl-talk] Regridding Moving Nest WRF outputs
>>> Message-ID:
>>> <CADK-_pk3useTuU96-xPmzL-u5bccCPtBnU5BuQpGAUULciNtww at mail.gm
>>> ail.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Good morning,
>>>
>>> I'm trying to regrid from a WRF grid (curvilinear) to ECMWF grid
>>> (rectilinear). The issue is that my WRF outputs are now obtained using
>>> the
>>> Moving Nest configuration. Therefore, I have a new high-resolution domain
>>> (D02) for each time step (I attach an example of what I'm saying).
>>> When D02 was fixed at specific lat/lon coordinates (i.e., without using
>>> the
>>> Moving Nest configuration) I used the rcm2rgrid function. But I do not
>>> know
>>> if I can use the same function now.
>>>
>>> Thanks in advance!
>>>
>>> Regards,
>>> Lara.
>>>
>>> --
>>>
>>>
>>> *Lara Quiti?n Hern?ndez, PhD Student*
>>> Departamento de F?sica de la Tierra, Astronom?a y Astrof?sica
>>> Facultad de Ciencias F?sicas
>>> Ciudad Universitaria, Plaza Ciencias, 1
>>> <https://maps.google.com/?q=Plaza+Ciencias,+1+%0D%0A28040+Madrid.+Spain&entry=gmail&source=g>
>>> 28040 Madrid. Spain
>>> Email: lquitian at ucm.es <mlunar at aemet.es>
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0316/101a4013/attachment.html>
>>> -------------- next part --------------
>>> A non-text attachment was scrubbed...
>>> Name: D02_MovingNest.gif
>>> Type: image/gif
>>> Size: 353984 bytes
>>> Desc: not available
>>> URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/2018
>>> 0316/101a4013/attachment.gif>
>>>
>>> ------------------------------
>>>
>>> Subject: Digest Footer
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>> ------------------------------
>>>
>>> End of ncl-talk Digest, Vol 172, Issue 30
>>> *****************************************
>>>
>>
>>
>>
>> --
>> *Colin Raymond*
>> Ph.D. Student, Ocean & Climate Physics
>> Columbia University
>>
>
>
--
*Colin Raymond*
Ph.D. Student, Ocean & Climate Physics
Columbia University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180317/810435fe/attachment.html>
More information about the ncl-talk
mailing list