Re: Regrid error : area_conserve_remap

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sun Sep 25 2011 - 19:48:43 MDT

[1] Your data span longitudes -35.75 to 35.75
[2] Your newlon are 0=>359. (really, should be 0=>357.5)
     I would suggest: newlon = fspan(-180, 177.5,144)
     Then data and grid are on same grid
[3] If you need 0=>357.5 then use 'lonFlip' to reorder

I think there must be something else wrong also but the above
gets some things correct

On 9/25/11 11:53 AM, Erik Noble wrote:
> Ok. Thank you. One last question please.
>
> The area_hi2lores_Wrap function seems to work, but the resulting output
> ends up having no data written to it (missing data). The file I read had
> data, but the output does not.
> When I use the printMinMax function, I see that it only sees the
> FillValue. This is wrong. How may I fix this so that I am correctly
> regridding the data?
> Is this time to use the Where function?
>
> (0) y-wind component: min=9.96921e+36 max=9.96921e+36
> (0) min=9.96921e+36 max=9.96921e+36
>
>
> [eunoble@discover18] tmp $ ncl test_regrid.ncl
> Copyright (C) 1995-2011 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) ***************************************************************
> (0) These are the WRF Model output files you are extracting from.
> (0) number of FILES = 97
> (0) ***************************************************************
> (0) Extracting WRF Model Output Variables
>
> Variable: U
> Type: float
> Total Size: 6844488 bytes
> 1711122 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 1] x [lev | 14] x [lat | 311] x [lon | 393]
> Coordinates:
> time: [0..0]
> lev: [1000..50]
> lat: [-18.40244..35.33525]
> lon: [-35.74922..35.74922]
> Number Of Attributes: 6
> _FillValue : 9.96921e+36
> description : y-wind component
> units : m s-1
> coordinates : lat lon
> stagger :
> FieldType : 104
>
> Variable: Uo
> Type: float
> Total Size: 588672 bytes
> 147168 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 1] x [lev | 14] x [lat | 73] x [lon | 144]
> Coordinates:
> time: [0..0]
> lev: [1000..50]
> lat: [-90..90]
> lon: [ 0..359]
> Number Of Attributes: 6
> _FillValue : 9.96921e+36
> description : y-wind component
> units : m s-1
> coordinates : lat lon
> stagger :
> FieldType : 104
> (0)
> (0) y-wind component: min=9.96921e+36 max=9.96921e+36
>
> Variable: Vo
> Type: float
> Total Size: 588672 bytes
> 147168 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 1] x [lev | 14] x [lat | 73] x [lon | 144]
> Coordinates:
> time: [0..0]
> lev: [1000..50]
> lat: [-90..90]
> lon: [ 0..359]
> Number Of Attributes: 1
> _FillValue : 9.96921e+36
> (0)
> (0) min=9.96921e+36 max=9.96921e+36
> (0) ***************************************************************
> (0) Writing out netcdf file:
> ncep2_grid_wrfout_d01_2006-09-02_00:00:00_wind_diagnostics.nc
> <http://00_wind_diagnostics.nc>
>
>
> SCRIPT
> [eunoble@discover18] tmp $ cat test_regrid.ncl
> ;***************************************************************
> ; Load Libaries
> ;***************************************************************
> 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/csm/contributed.ncl"
>
> begin
> ;***************************************************************
> ; Change these parts
> ;***************************************************************
> DATADir = "./" ;input directory
> Files = "wrfout_d01*_wind_diagnostics*"
> ;input files
> ncdiro = "./" ;output directory
> NCFILE1 = "ncep2_grid" ;output file
> ;***************************************************************
> ; Read in WRF Files
> ;***************************************************************
> ;FILES = systemfunc (" ls -1 " + DATADir + Files) ; file paths
> FILES = systemfunc (" ls -1 " + Files) ; file paths
> numFILES = dimsizes(FILES)
>
> print("***************************************************************")
> print("These are the WRF Model output files you are extracting from.")
> print("number of FILES = " + numFILES)
> ; print(FILES)
>
> print("***************************************************************")
> print ("Extracting WRF Model Output Variables")
> ;**************************************
> ; DO LOOP: Extraction
> ;**************************************
> ; Use wrf_user_getvar function to extract each variable.
> ; "-1" means all times, which doesn't matter here
> ; b/c there is only 1 time in each file
> ;************************************
> deltaTime = ispan(0,numFILES-1,1)
> do ifil = 0,0,1 ;0,numFILES-1
> a = addfile(FILES(ifil)+".nc","r") ;read individual wrfout file
> U = a->U
> V = a->V
> printVarSummary(U)
>
> ;************************************************
> ; interpolate to new grid (NCEP R2 2.5 GRID --> 73,144)
> ;***********************************************
> loni = U&lon
> lati = U&lat
> newlat = fspan(-90.,90,73)
> newlon = fspan(0.,359.,144)
> newlat@units = "degrees_north"
> newlon@units = "degrees_east"
>
>
> ; Uo = area_conserve_remap_Wrap (loni,lati,U, newlon,newlat, False)
> Uo = area_hi2lores_Wrap (loni,lati,U,False, 1, newlon,newlat,
> False)
> Uo!2 = "lat"
> Uo!3 = "lon"
> ;Uo@_FillValue= -9999
> printVarSummary(Uo)
> printMinMax(Uo,True)
> Vo = area_hi2lores_Wrap (loni,lati,V,False, 1, newlon,newlat,
> False)
> Vo!2 = "lat"
> Vo!3 = "lon"
> ;Vo@_FillValue = -9999
> printVarSummary(Vo)
> printMinMax(Vo,True)
> ;***************************************************************
> ; Write out to netcdf
> ;***************************************************************
>
> print("***************************************************************")
> NCFILE = NCFILE1+"_"+FILES(ifil)
> print( "Writing out netcdf file: "+NCFILE)
> system("/bin/rm -f "+ncdiro+NCFILE) ; remove any pre-existing file
> ncdf = addfile(ncdiro+NCFILE ,"c") ; open output netCDF file
> ; make time and UNLIMITED dimension ; recommended for most
> applications
> filedimdef(ncdf,"time",-1,True)
> ;******** VARIABLES *****************
> ncdf->U=Uo
> ncdf->V=Vo
>
> end do
> end
>
> On Sun, Sep 25, 2011 at 9:40 AM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> I would suggest using
>
> Uo = area_hi2lores_Wrap (loni,lati,U,False, 1, newlon,newlat, False)
>
> Good Luck
>
>
> On 9/24/11 6:27 PM, Erik Noble wrote:
>
> Hi. Ok. I missed the part on the example page that says this
> function
> assumes the input is global. It is not.
> To make this work, the page says I need to declare the
> "dimension of the
> *global* latitude set of which the grid is a subset."
> My model data is on a 20km by 20km regional grid. Do I need to
> make this
> declaration in "degrees" only.
>
> opt = True
> opt@NLATi = ???
>
>
>
> On Sat, Sep 24, 2011 at 7:20 PM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>
> <mailto:shea@ucar.edu <mailto:shea@ucar.edu>>> wrote:
>
> area_conserve_remap requires that *both* the input and
> output grid
> be global. The input grid
>
> Variable: U
> [snip]
>
> lat: [-18.40244..35.33525]
> lon: [-35.74922..35.74922]
>
> is not global
>
>
> On 9/24/11 2:30 PM, Erik Noble wrote:
>
> Hi. I am trying to remap a hi resolution file to a 2.5
> degree global
> grid, similar to NCEP Reanalysis II, so that I can
> compare data. I'm
> following the examples using the area_conserve_remap
> function.
> http://www.ncl.ucar.edu/____Document/Functions/____Contributed/area_conserve_____remap_Wrap.shtml
> <http://www.ncl.ucar.edu/__Document/Functions/__Contributed/area_conserve___remap_Wrap.shtml>
> <http://www.ncl.ucar.edu/__Document/Functions/__Contributed/area_conserve___remap_Wrap.shtml
> <http://www.ncl.ucar.edu/Document/Functions/Contributed/area_conserve_remap_Wrap.shtml>>
> I keep getting this error:
>
> Error in "cremapbin":
> Could not map global lat array into grid array
> Segmentation fault
>
> I am not sure where I am creating this error. Could I please
> have some
> help with this?
> Sincerely,
> Erik
>
>
> [eunoble@borg01t008] Experiment_01 $ ncl test_regrid.ncl
> Copyright (C) 1995-2011 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0)
>
> ******************************____****************************__**__***
> (0) These are the WRF Model output files you are
> extracting from.
> (0) number of FILES = 97
> (0)
>
> ******************************____****************************__**__***
> (0) Extracting WRF Model Output Variables
>
> Variable: U
> Type: float
> Total Size: 6844488 bytes
> 1711122 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 1] x [lev | 14] x [lat
> | 311] x
> [lon | 393]
> Coordinates:
> time: [0..0]
> lev: [1000..50]
> lat: [-18.40244..35.33525]
> lon: [-35.74922..35.74922]
> Number Of Attributes: 6
> _FillValue : 9.96921e+36
> description : y-wind component
> units : m s-1
> coordinates : lat lon
> stagger :
> FieldType : 104
> Error in "cremapbin":
> Could not map global lat array into grid array
> Segmentation fault
>
>
> ;;;;;;;;;;;;;;;; NCL SCRIPT
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;____;;;;;;;;;;;;;;;;;;;
>
>
> ;*****************************____****************************__**__****
> ; Load Libaries
>
> ;*****************************____****************************__**__****
> 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/csm/contributed.____ncl"
>
> begin
>
>
> ;*****************************____****************************__**__****
> ; Change these parts
>
>
> ;*****************************____****************************__**__****
> DATADir = "./" ;input
> directory
> Files = "wrfout_d01*_wind_diagnostics.____nc
> <http://wind_diagnostics.nc>
> <http://wind_diagnostics.nc>" ;input files
>
> ncdiro = "./"
> ;output directory
> NCFILE1 = "wind_diagnostics" ;output file
>
>
> ;*****************************____****************************__**__****
> ; Read in WRF Files
>
>
> ;*****************************____****************************__**__****
> ;FILES = systemfunc (" ls -1 " + DATADir + Files) ;
> file paths
> FILES = systemfunc (" ls -1 " + Files) ; file paths
> numFILES = dimsizes(FILES)
>
>
> print("***********************____****************************__**__**********")
> print("These are the WRF Model output files you are
> extracting from.")
> print("number of FILES = " + numFILES)
> ;print(FILES)
>
>
> print("***********************____****************************__**__**********")
> print ("Extracting WRF Model Output Variables")
> ;*****************************____*********
> ; DO LOOP: Extraction
> ;*****************************____*********
> ; Use wrf_user_getvar function to extract each
> variable.
> ; "-1" means all times, which doesn't matter here
> ; b/c there is only 1 time in each file
> ;*****************************____*******
> deltaTime = ispan(0,numFILES-1,1)
> do ifil = 0,0,1 ;0,numFILES-1
> a = addfile(FILES(ifil)+".nc","r") ;read
> individual
> wrfout file
> U = a->U
> V = a->V
> printVarSummary(U)
>
>
> ;*****************************____*******************
> ; interpolate to new grid (NCEP R2 2.5 GRID -->
> 73,144)
>
> ;*****************************____******************
> loni = U&lon
> lati = U&lat
> newlat = fspan(-90.,90,73)
> newlon = fspan(0.,359.,144)
> newlat@units = "degrees_north"
> newlon@units = "degrees_east"
>
>
> Uo = area_conserve_remap_Wrap (loni,lati,U,
> newlon,newlat, False)
> printVarSummary(Uo)
>
> end do
> end
>
>
>
>
>
> ___________________________________________________________
> Erik Noble
> Center for Climate Systems Research, Columbia University
> NASA Goddard Institute for Space Studies
> 2880 Broadway, New York, NY-10025, USA
>
> Tel: +1 (212) 678-5512 <tel:%2B1%20%28212%29%20678-5512>
> <tel:%2B1%20%28212%29%20678-__5512>; Fax:
> +1 (212) 678-5552 <tel:%2B1%20%28212%29%20678-5552>
> <tel:%2B1%20%28212%29%20678-__5552>
>
> E-mail: enoble@giss.nasa.gov
> <mailto:enoble@giss.nasa.gov> <mailto:enoble@giss.nasa.gov
> <mailto:enoble@giss.nasa.gov>>
> <mailto:enoble@giss.nasa.gov <mailto:enoble@giss.nasa.gov>
> <mailto:enoble@giss.nasa.gov <mailto:enoble@giss.nasa.gov>>>__,
>
> en2192@columbia.edu <mailto:en2192@columbia.edu>
> <mailto:en2192@columbia.edu <mailto:en2192@columbia.edu>>
> <mailto:en2192@columbia.edu <mailto:en2192@columbia.edu>
> <mailto:en2192@columbia.edu <mailto:en2192@columbia.edu>>>
>
>
> WEB: http://www.giss.nasa.gov/____staff/enoble.html
> <http://www.giss.nasa.gov/__staff/enoble.html>
> <http://www.giss.nasa.gov/__staff/enoble.html
> <http://www.giss.nasa.gov/staff/enoble.html>>
> GISS: http://www.giss.nasa.gov
> CCSR: http://www.ccsr.columbia.edu
> ___________________________________________________________
>
>
>
> ___________________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/____mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/__mailman/listinfo/ncl-talk>
> <http://mailman.ucar.edu/__mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>>
>
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Sep 25 19:48:50 2011

This archive was generated by hypermail 2.1.8 : Mon Sep 26 2011 - 14:45:50 MDT