Re: problem with dimensions

From: Jenny Brandefelt <jenny_at_nyahnyahspammersnyahnyah>
Date: Fri, 28 Apr 2006 18:28:53 +0200

Hi Adam,

Thank you very much for your help and explanations!
Now it works fine and I get my EOFs.

Jenny

Adam Phillips wrote:
> Hi Jenny,
>
> Whenever you get an "Assignment type mismatch, right hand side can't be
> coerced to type of left hand side" error message, it means you are
> trying to pass one type of data array into another type of data array.
> For instance, trying to pass floats into an integer array...
>
> In this case, you are trying to pass doubles into a float array. For the
> line in question:
> wslp = tmp
>
> tmp is a double array, while wslp is a float. tmp is a double array
> because clat is a double array. (When you multiply clat (double) * slp
> (float), the resulting array will be of type double.)
>
> Anyway, for the last few lines of your code try this:
>
> printVarSummary(clat)
> printVarSummary(wslp)
> printVarSummary(tmp)
> wslp = (/ dble2flt(tmp) /)
> printVarSummary(wslp)
>
> I used dble2flt to convert tmp to a float array, and surrounded it with
> (/ /) so that NCL will not wipe out the metadata on the lefthand side.
>
> Good luck,
> Adam
>
>
> Jenny Brandefelt wrote:
>
>> Hi!
>>
>> I want to use NCL to determine EOF's of CCSM surface pressure.
>>
>> Before the EOF analysis I want to multiply the data with the
>> appropriate gaussian weights. But NCL is not content with the
>> dimensions of my arrays.
>>
>> I would be most grateful if someone has an idea of what is wrong!
>>
>> The data file contains PS from a run with CCSM3 and is available
>> here:
>>
>> http://www.misu.su.se/~jenny/ps.b30.031.6.cam2.h0.0501-01.nc
>>
>>
>> Thanks,
>> Jenny Brandefelt
>>
>>
>>
>>
>> Output when trying to run my script:
>>
>> >ncl weight.ps.ncl
>> Copyright (C) 1995-2004 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 4.2.0.a032
>> The use of this software is governed by a License Agreement.
>> See http://ngwww.ucar.edu/ncl/ for more details.
>> (0) 1
>> (1) 48
>> (2) 96
>> (0) 1
>> (1) 48
>> (2) 96
>> fatal:Assignment type mismatch, right hand side can't be coerced to
>> type of left hand side
>> fatal:Execute: Error occurred at or near line 28 in file weight.ps.ncl
>>
>>
>>
>>
>> The script weight.ps.ncl:
>>
>> ; ==============================================================
>> ; Calculate EOFs of the Sea Level Pressure over the North Atlantic.
>> ; ==============================================================
>> 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
>> ; ==============================================================
>> ; Open the file: PS data span (year-month) 501-01 -- 501-12
>> ; ==============================================================
>> f = addfile ("./ps.b30.031.6.cam2.h0.0501-01.nc", "r")
>> slp = f->PS
>> ; -----------------------------------------------------------------
>> ; create weights: sqrt(cos(lat)) [or sqrt(gw) ]
>> ; -----------------------------------------------------------------
>> rad = 4.*atan(1.)/180.
>> clat = f->lat
>> clat = sqrt( cos(rad*clat) ) ; gw for gaussian grid
>> ; -----------------------------------------------------------------
>> ; weight all observations
>> ; -----------------------------------------------------------------
>> wslp = slp ; copy meta data
>> tmp = slp*conform(slp, sqrt(clat), 1)
>> print(dimsizes(slp))
>> print(dimsizes(tmp))
>> wslp = tmp
>> end
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jenny Brandefelt,  http://www.misu.su.se/~jenny
Department of Meteorology, Stockholm University
phone: +46-8-164337, fax: +46-8-157185
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Apr 28 2006 - 10:28:53 MDT

This archive was generated by hypermail 2.2.0 : Fri Apr 28 2006 - 10:57:15 MDT