[ncl-talk] Calculating Barotropic streamfunction and AMOC using data with missing values?
Mary Haley
haley at ucar.edu
Thu Sep 18 12:22:26 MDT 2014
Michael,
The error telling you exactly what the the problem is: the first argument
must be a float or double. But, your "printVarSummary" output seems to
indicate that your arrays are float, so I'm not sure why you are getting
this error.
poisson_grid_fill is working just fine for me using either float or double
input, so maybe there's a different issue. What version of NCL do you have?
--Mary
On Sat, Sep 6, 2014 at 4:57 AM, Hemming, Michael <
michael.hemming at mpimet.mpg.de> wrote:
> Hi Mary,
>
> Thanks for the suggestion. I have since been told that the data has been
> conservatively interpolated onto a regular grid from the original
> triangular grid, so this command may work. Although, I am having trouble
> understanding exactly what it does. I guess it is a form of interpolation
> but I'm not sure what the following means and how I should change this to
> suit my data:
>
> guess = 1 ; use zonal means
> is_cyclic = True ; cyclic [global]
> nscan = 1500 ; usually much less than this
> eps = 1.e-2 ; variable dependent
> relc = 0.6 ; relaxation coefficient
> opt = 0 ; not used
>
> and I also have the problem of missing values for the following script,
> where it complains about missing values at the line including ' zone_int =
> new((/nlat........':
>
>
>
> 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
>
> ;##########################################################################
> ;##########################################################################
> ;--------------------------------AMOC Plots--------------------------------
> ;--------------------------------------------------------------------------
> ;##########################################################################
> ;##########################################################################
>
> ; Adapted from: http://www.ncl.ucar.edu/Applications/Scripts/moc_1.ncl
>
> ;**************************************************************
> ; read in data
> ;**************************************************************
>
> in = addfile("sector_icon_lr_13_mpiom_data_3du_ym_0000-0099.nc","r")
>
> v = in->vke
> dz = in->depth
> dx = in->uko ;if doesn't work check this line!
> lat= in->lat
>
> poisson_grid_fill( v, True, 1, 1500, 1e-2, 0.6, 0)
> poisson_grid_fill( dx, True, 1, 1500, 1e-2, 0.6, 0)
>
>
> dxx = rm_single_dims(dx({depth|7},{lon|-45:-45},{lat|-30:-30},time|:))
>
> printVarSummary(v)
> printVarSummary(dz)
> printVarSummary(dx)
> printVarSummary(dxx)
> printVarSummary(lat)
>
>
> ;**************************************************************
> ; some parameters
> ;**************************************************************
>
>
> nzt = getfilevardimsizes(in,"z_t") ; z_t grid (25)
> nzw = nzt+1 ; z_w grid (26)
> nlat = dimsizes(lat)
>
> d2rad = 0.017453 ; degrees to radians
>
> printVarSummary(nzt)
> printVarSummary(nzw)
> printVarSummary(nlat)
>
>
> ;**************************************************************
> ; calculate first intergral
> ; int[lon1:lon2]v*cos(lat)*dx*dz
> ; this calculation is done on the z_t grid
> ;**************************************************************
>
>
> zone_int = new((/nlat,nzt/),typeof(v)) ; allocate space
> do k = 0, nzt-1
> do j = 0, nlat-1
> zone_int(j,k) = dim_sum(v(k,j,:)*cos(lat(j)*d2rad)*dxx*dz(k))
> end do
> end do
> printVarSummary(zone_int)
>
>
>
>
>
>
> The results from using PrintVarSummary:
>
>
>
>
> Variable: v
> Type: float
> Total Size: 40992000 bytes
> 10248000 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 100] x [depth | 20] x [lat | 122] x [lon |
> 42]
> Coordinates:
> time: [ 0..867240]
> depth: [ 7..2435]
> lat: [45.375..-45.375]
> lon: [-51.375..-20.625]
> Number Of Attributes: 6
> standard_name : sea_water_y_velocity
> long_name : Sea water y velocity
> units : m s-1
> code : 4
> _FillValue : -9e+33
> missing_value : -9e+33
>
> Variable: dz
> Type: double
> Total Size: 160 bytes
> 20 values
> Number of Dimensions: 1
> Dimensions and sizes: [depth | 20]
> Coordinates:
> depth: [ 7..2435]
> Number Of Attributes: 5
> standard_name : depth
> long_name : depth_below_sea
> units : m
> positive : down
> axis : Z
>
> Variable: dx
> Type: float
> Total Size: 40992000 bytes
> 10248000 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 100] x [depth | 20] x [lat | 122] x [lon |
> 42]
> Coordinates:
> time: [ 0..867240]
> depth: [ 7..2435]
> lat: [45.375..-45.375]
> lon: [-51.375..-20.625]
> Number Of Attributes: 6
> standard_name : sea_water_x_velocity
> long_name : Sea water x velocity
> units : m s-1
> code : 3
> _FillValue : -9e+33
> missing_value : -9e+33
>
> Variable: dxx
> Type: float
> Total Size: 400 bytes
> 100 values
> Number of Dimensions: 1
> Dimensions and sizes: [time | 100]
> Coordinates:
> time: [ 0..867240]
> Number Of Attributes: 9
> lon : -45.375
> lat : -29.625
> depth : 7
> missing_value : -9e+33
> _FillValue : -9e+33
> code : 3
> units : m s-1
> long_name : Sea water x velocity
> standard_name : sea_water_x_velocity
>
> Variable: lat
> Type: double
> Total Size: 976 bytes
> 122 values
> Number of Dimensions: 1
> Dimensions and sizes: [lat | 122]
> Coordinates:
> lat: [45.375..-45.375]
> Number Of Attributes: 4
> standard_name : latitude
> long_name : latitude
> units : degrees_north
> axis : Y
>
> Variable: nzt
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : -2147483647
>
> Variable: nzw
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : -2147483647
>
> Variable: nlat
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
>
>
> The error:
>
> fatal:poisson_grid_fill: The first input argument must be float or double
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 64 in
> file AMOC.ncl
>
>
>
>
>
> thanks,
> Michael
>
>
> ------------------------------
> *From:* Mary Haley [haley at ucar.edu]
> *Sent:* 05 September 2014 19:59
> *To:* Hemming, Michael
> *Cc:* ncl-talk at ucar.edu Talk
> *Subject:* Re: [ncl-talk] Calculating Barotropic streamfunction and AMOC
> using data with missing values?
>
> Hi Michael,
>
> I'm hoping Dennis will weigh in here.
>
> You really don't want to use the spherical harmonic routines on missing
> data. Normally I would say you need to regrid the data or use
> poisson_grid_fill first so you can get rid of missing values, but given
> that this is UV data, I don't think this is your best option.
>
> --Mary
>
>
>
> On Tue, Sep 2, 2014 at 5:16 AM, Michael Hemming <
> michael.hemming at mpimet.mpg.de> wrote:
>
>> Hello,
>>
>> I have been struggling to calculate Barotropic streamfunction and AMOC
>> using online examples and function but I have recently been told it is due
>> to the fact that the data I use contains missing values, therefore all
>> values are set to the missing value.
>>
>> How can I somehow ignore the missing values during calculation?
>>
>> Here is my code for the bartropic streamfunction:
>>
>>
>> ----------------------------------------------------------------------------------------------------------------------------------------------------
>>
>> 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
>>
>>
>> ;##########################################################################
>>
>> ;##########################################################################
>> ;-------------------------Barotropic
>> Plots---------------------------------
>>
>> ;--------------------------------------------------------------------------
>>
>> ;##########################################################################
>>
>> ;##########################################################################
>>
>> ;----------Load in data
>>
>> ;ICON
>>
>> noshupw = addfile ("con.ym.atlbox.noshift.100y.nc", "r")
>> u = noshupw->u_vint_acc
>> u&lon = u&lon-360 ; Fix the longitudes to be < 360
>> lat = noshupw->lat
>>
>>
>> v = noshupw->v_acc
>>
>> printVarSummary(u)
>> printVarSummary(v)
>>
>> dimUV= dimsizes(barai)
>>
>> klev = 20 ; number of levels in total
>>
>> sf = v(:,{klev},:,:)
>> vp = v(:,{klev},:,:)
>> sf at long_name = "stream function"
>> vp at long_name = "velocity potential"
>> sf at units = "m^2/s"
>> vp at units = "m^2/s"
>>
>> printVarSummary(sf)
>> printVarSummary(vp)
>>
>> uv2sfvpg(u,v,sf,vp)
>>
>>
>>
>> ----------------------------------------------------------------------------------------------------------------------------------------------------
>>
>> and my AMOC code is largely based on the online example moc_1.ncl
>>
>>
>>
>> thanks,
>> Michael
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> 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/20140918/26b8a707/attachment.html
More information about the ncl-talk
mailing list