Re: problem with region_ind function

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 12 2013 - 11:01:18 MDT

Hi Mira,

It appears that you are doing everything correctly. But, without your data file, I don't know how the lat/lons are spaced.

Also, depending on what type of 2D grid you have, "region_ind" may not be appropriate.

Can you provide the file?

--Mary

On Jul 11, 2013, at 10:20 AM, Mira Berdahl <mberdahl@envsci.rutgers.edu> wrote:

> Hi,
>
> I am trying to subset a region in the North Atlantic from an ocean grid
> with 2d lat and lon. I am following example 1 here:
> http://www.ncl.ucar.edu/Document/Functions/Contributed/region_ind.shtml
>
> However, when I output the subsetted lat/lon range, it does not match the
> range I request in the script (below).
>
> Does anyone see why this might be?
> Thanks in advance,
> Mira
>
> ;************************************************
> ; NA_tos.ncl
> ;************************************************
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/popRemap.ncl"
> ;************************************************
> begin
>
>
> ;%%%%% read CCSM4 data%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> in = addfile("tos_Omon_CCSM4_past1000_r1i1p1_110001-134912.nc","r")
>
> glat2d = in->lat
> glon2d = in->lon
>
> printMinMax(glat2d,True)
> printMinMax(glon2d,True)
>
> ; region to subset
> latS = 50 ; North Atlantic
> latN = 65
> lonW = 310
> lonE = 340
>
> ji = region_ind(glat2d, glon2d,latS,latN,lonW,lonE)
>
> jStrt = ji(0) ; lat start
> jLast = ji(1) ; lat last
> iStrt = ji(2) ; lon start
> iLast = ji(3) ; lon last
>
> LAT2D = glat2d(jStrt:jLast,iStrt:iLast)
> LON2D = glon2d(jStrt:jLast,iStrt:iLast)
>
> printMinMax(LAT2D,True)
> printMinMax(LON2D,True)
>
> ; read data just for the region fo interest
> x_1100_1350 = in->tos(:,jStrt:jLast,iStrt:iLast)
>
> printVarSummary(x_1100_1350)
>
> ;%%%%% read in the weights (area of grid cells %%%%%%%%%%%%%%%%
> in = addfile("areacello_fx_CCSM4_past1000_r0i0p0.nc","r")
>
> x_area = in->areacello(jStrt:jLast,iStrt:iLast)
> printVarSummary(x_area)
>
> ;%%% calculate the area weighted NA temperature --- based on area of grid
> cells.
> NA_tos_ccsm4_1100_1350 = wgt_areaave2(x_1100_1350 ,x_area,0)
>
> asciiwrite("NA.tos.ccsm4.1100.1350.asc",NA_tos_ccsm4_1100_1350)
>
>
> end
>
>
> [mlosic@ncoeus Ocean]$ ncl testing_ccsm4.ncl
> Copyright (C) 1995-2009 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.1.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0)
> (0)glat2d: latitude coordinate: min=-79.2205 max=89.7064
> (0)
> (0)glon2d: longitude coordinate: min=0.0147311 max=359.996
> (0)
> (0)LAT2D: latitude coordinate: min=49.7087 max=89.1075
> (0)
> (0)LON2D: longitude coordinate: min=0.0155527 max=359.974
>
>
> Variable: x_1100_1350
> Type: float
> Total Size: 153600000 bytes
> 38400000 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 3000] x [j | 40] x [i | 320]
> Coordinates:
> time: [401515..492734.5]
> j: [327..366]
> i: [1..320]
> Number Of Attributes: 13
> standard_name : sea_surface_temperature
> long_name : Sea Surface Temperature
> comment : TEMP at topmost level, units from C to K,
> CMIP5_table_comment: "this may differ from ""surface temperature"" in
> regions of sea ice."
> units : K
> original_name : TEMP
> original_units : degC
> history : 2012-03-13T22:34:24Z altered by CMOR: Converted units from
> 'degC' to 'K'. 2012-03-13T22:34:24Z altered by CMOR: replaced missing
> value flag (9.96921e+36) with standard missing value (1e+20).
> cell_methods : time: mean (interval: 30 days)
> cell_measures : area: areacello
> missing_value : 1e+20
> _FillValue : 1e+20
> associated_files : baseURL:
> http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile:
> gridspec_ocean_fx_CCSM4_past1000_r0i0p0.nc areacello:
> areacello_fx_CCSM4_past1000_r0i0p0.nc
> coordinates : lat lon
>
>
> Variable: x_area
> Type: float
> Total Size: 51200 bytes
> 12800 values
> Number of Dimensions: 2
> Dimensions and sizes: [j | 40] x [i | 320]
> Coordinates:
> j: [327..366]
> i: [1..320]
> Number Of Attributes: 11
> standard_name : cell_area
> long_name : Ocean Grid-Cell Area
> units : m2
> original_name : TAREA
> comment : TAREA convert cm2 to m2
> original_units : centimeter^2
> history : 2012-02-02T18:54:47Z altered by CMOR: Converted units from
> 'centimeter^2' to 'm2'. 2012-02-02T18:54:47Z altered by CMOR: replaced
> missing value flag (9.96921e+36) with standard missing value (1e+20).
> missing_value : 1e+20
> _FillValue : 1e+20
> associated_files : baseURL:
> http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile:
> gridspec_ocean_fx_CCSM4_past1000_r0i0p0.nc
> coordinates : lat lon
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> 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 Fri Jul 12 11:01:29 2013

This archive was generated by hypermail 2.1.8 : Fri Jul 12 2013 - 16:37:39 MDT