[gradsusr] How to define this formula?
Jeff Duda
jeffduda319 at gmail.com
Sun Feb 3 13:29:00 EST 2013
T.,
Whenever you have multiple files open simultaneously, you need to use a .n
appended to the variable name to reference the file. It seems in your
case, the variable in the second file is also TK, but you would need to
refer to it as TK.2. Also, you have open statements in your while loop,
but no close statements. Thus you will continue to open new files that
will need successively higher reference numbers (.3, .4, etc). Either use
an index variable outside of quotes as the reference OR close each file at
the end of each iteration of the loop. Finally, remember to enclose
statements in quotes if you would enter them at the Grads command prompt
(like setting lat and lon values).
Jeff
On Sun, Feb 3, 2013 at 12:14 PM, T. haghroosta <haghroosta at hotmail.com>wrote:
> Dear Jeff Duda,
>
> I did your suggestion as follows. As an extra explanation, I would like to
> calculate RMSE for a special parameter like TK during four days in a
> special Lon and Lat. I also have two files, observed and simulated. So, I
> wrote this script, but it didn't work. Could you please help me? Another
> question how can I show the last output (RMSE)?
>
> t=1
> pow=0
> 'reinit'
> while(t<=4)
> 'sdfopen observed.nc'
> lon= 100
> lat= 21
> TK1=TK
> 'close 1'
> 'open simulated.ctl'
> TK2=TK
> 'pow1=pow(TK1(t)-TK2(t))
> 'pow = pow + pow1
> t=t+1
> endwhile
> 'RMSE= sqrt(pow/t)'
>
> Regards,
>
> T.
>
>
>
> >
> > Today's Topics:
> >
> > 1. How to define this formula? (T. haghroosta)
> > 2. Re: How to define this formula? (Jeff Duda)
> > 3. Re: lon lat to km (wendi harjupa)
> >
> >
> > --------------------------------------------------------------! --------
> >
> > Message: 1
> > Date: Sun, 3 Feb 2013 05:24:48 +0000
> > From: "T. haghroosta" <haghroosta at hotmail.com>
> > Subject: [gradsusr] How to define this formula?
> > To: <gradsusr at gradsusr.org>
> > Message-ID: <DUB121-W214D8BDEBA3D102D60AD37DD020 at phx.gbl>
> > Content-Type: text/plain; charset="windows-1256"
>
> >
> >
> >
> >
> >
> > Dear All, Could you please tell me how can I define this equation which
> I have attached to the email. I got confused completely, I did somethings
> that don't work.
> >
> > Regards, T.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130203/f3a4e!
> 59a/attachment-0001.html
> > -------------- next part ----------- ---
> > A non-text attachment was scrubbed...
> > Name: D.jpg
> > Type: image/jpeg
> > Size: 6713 bytes
> > Desc: not available
> > Url :
> http://gradsusr.org/pipermail/gradsusr/attachments/20130203/f3a4e59a/attachment-0001.jpg
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Sun, 3 Feb 2013 01:53:22 -0600
> > From: Jeff Duda <jeffduda319 at gmail.com>
> > Subject: Re: [gradsusr] How to define this formula?
> > To: GrADS Users Forum <gradsusr at gradsusr.org>
> > Message-ID:
> > <CAAig09DhORYVv_MLG58R5SEAv9pypU41igt_7XwYt97v9Ljocw at mail.gmail.com>
> > Content-Type: text/plain; charset="iso-8859-1"
>
> >
> > That looks like standard deviation or RMSE. Either way, assume your array
> > is VAR. Then it's
> >
> > C = sqrt(amean(asum(pow(VAR -
> > amean(VAR,x=x1,x=x2,y=y1,y=y2)),2),x=x1,x=x2,y=y1,y=y2))
> >
> > OR
> >
> > C = sqrt(asum(V! AR - amean(VAR,x=x1,x=x2,y=y1,y=y2))/N), where N is the
>
> > number of grid points over which you're summing.
> >
> > You'll have to insert values for x1, x2, y1, and y2 yourself. You can use
> > lat and lon instead of y and x, though.
> >
> > If that fails, try breaking it into parts:
> > 'average = amean(VAR,x=x1,x=x2,y=y1,y=y2)'
> > 'diffsquaredsum = asum(pow(VAR-average,2),x=x1,x=x2,y=y1,y=y2)'
> > 'SD (or) RMSE = sqrt(diffsquaredsum/N)'
> >
> > Jeff Duda
> >
> > On Sat, Feb 2, 2013 at 11:24 PM, T. haghroosta <haghroosta at hotmail.com
> >wrote:
> >
> > > Dear All,
> > >
> > > Could you please tell me how can I define this equation which I have
> > > attached to the email. I got confused completely, I did somethings that
> > > don't work.
> > >
> > > Regards,
> > >
> > > T.
> > >
> > > **** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *!
> *************************
> > > ** **** ********
> > >*> > _______________________________________________
>
> > > gradsusr mailing list
> > > gradsusr at gradsusr.org
> > > http://gradsusr.org/mailman/listinfo/gradsusr
> > >
> > >
> >
> >
> > --
> > Jeff Duda
> > Graduate research assistant
> > University of Oklahoma School of Meteorology
> > Center for Analysis and Prediction of Storms
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL:
> http://gradsusr.org/pipermail/gradsusr/attachments/20130203/0cd5f463/attachment-0001.html
> >
> > ------------------------------
> >
> > Message: 3
> > Date: Sun, 3 Feb 2013 21:55:53 +0900
> > From: wendi harjupa <wendiharjupa at gmail.com>
> > Subject: Re: [gradsusr] lon lat to km
> > To: GrADS Users Forum <gradsusr at gradsusr.org>
> > Message-ID:
> > <CA+u6P9METKDdi6QQkH-FZT7mMzcFSAR17MeuvY-hiOkwYQn6Ow at mail.gmail.com>!
> > Content-Type: text/plain; charset="iso-8859-1"
> >
> > Dear Mr. Jeff
> >
> > Thank you very much for your guidance as far..
> > But, I am very sorry for asking you many times..
> > since it is very difficult for me..
> >
> > I tried to change some parts of script, but still this did not run..
> > I got error message as below :
> >
> > Error from CDIFF: Specified dimension non varying
> > Operation Error: Error from cdiff function
> > Error ocurred at column 31
> > DEFINE error: Invalid expression.
> > *** glibc detected *** grads: corrupted double-linked list: 0x089e2918
> > ***
> > Would you mind to explain more??
> >
> > Thank you very much
> >
> > Best regards,
> > wendi
> >
> > On Sun, Feb 3, 2013 at 1:46 AM, Jeff Duda <jeffduda319 at gmail.com> wrote:
> >
> > > Use this code:
> > >
> > > 'reinit'
> > > 'open try2.ctl'!
> > > 'set grads off'
> > > 'set mproj latlon'
> > > 'set mpdset hires'
> > > 'set gxout shaded'
> > > 'set grid on'
> > > 'set lon 100 101'
> > > 'set lat -1 0'
> > > 'define dx =
> *6.371e3**cos(-1*(3.14159/180))*cdiff(100,0)*(3.14159/180)'
> > > 'define dy = *6.371e3**cdiff(-1,0)*(3.14159/180))'
> > > 'define xdist = ((lon-100)/0.004492369)*(dx/2)'
> > > 'define ydist = ((lat-0)/0.004522556)*(dy/2)'
> > > 'set z 5'
> > > 'set t 1'
> > > 'd ref'
> > >
> > > The square brackets were just to show different groupings. When it
> comes
> > > time to code it, you must use only parentheses.
> > >
> > > The above should work.
> > >
> > > Jeff
> > >
> > > On Sat, Feb 2, 2013 at 1:41 AM, wendi harjupa <wendiharjupa at gmail.com
> >wrote:
> > >
> > >> Dear Mr. Jeff
> > >>
> > >> Thank you very much for your explanation,
> > >> but I am very sorry, ! I still do not get it,
> > >>
> > >> I made new script
> > >>
> > >> 'reinit'
> > >> 'open try2.ctl'
> > >> 'set grads off'
> > >> 'set mproj latlon'
> > >> 'set mpdset hires'
> > >> 'set gxout shaded'
> > >> 'set grid on'
> > >> 'set lon 100 101'
> > >> 'set lat -1 0'
> > >> 'define dx =
> *6.371e3**cos(-1*(3.14159/180))*cdiff(100,0)*(3.14159/180)'
> > >> 'define dy = *6.371e3**cdiff(-1,0)*(3.14159/180))'
> > >> 'define xdist = ((lon-100)/0.004492369)*(dx/2]'
> > >> 'define ydist = ((lat-0)/0.004522556)*dy/2]'
> > >> 'set z 5'
> > >> 'set t 1'
> > >> 'd ref'
> > >>
> > >> I checked grads document and I found that 6.371e3 is radius of the
> earth
> > >> (6371 to 6374 km)*.*
> > >> *
> > >> *
> > >> *I tried to change "*6.371e3" to! "0e10" which is mean 0 to 10 km)
> > >> But still the progr am did not run normally.
> > >>
> > >> I changed the value of lon and lat in script with 100 and -1.
> > >> but still I got error.
> > >>
> > >> Please help me to solve it.
> > >>
> > >> Thank you very much
> > >> Best regards,
> > >> wendi
> > >>
> > >> On Sat, Feb 2, 2013 at 2:21 AM, Jeff Duda <jeffduda319 at gmail.com>
> wrote:
> > >>
> > >>> Wendi,
> > >>> You need to run those two define commands at the top of my previous
> > >>> email before attempting to define the xdist and ydist fields. Also,
> since
> > >>> I can see your control file information, I can see that dlon is
> 0.004492369
> > >>> and dlat is 0.004522556. So substitute those two values into your
> > >>> expressions for xdist and ydist also.
> > >>>
> > >>> Jeff
> > >>>> >>>
> > >>> On Fri, Feb 1, 2013 at 4:36 AM, wendi harjupa <
> wendiharjupa at gmail.com>wrote:
> > >>>
> > >>>> Dear Mr. Jeff
> > >>>>
> > >>>> I have tried to use the scipt which you suggested,
> > >>>> But, still I could not do it. Would you help me more...
> > >>>>
> > >>>> here I send my gs file :
> > >>>>
> > >>>> 'reinit'
> > >>>> 'open try2.ctl'
> > >>>> 'set grads off'
> > >>>> 'set mproj latlon'
> > >>>> 'set mpdset hires'
> > >>>> 'set gxout shaded'
> > >>>> 'set grid on'
> > >>>> 'set lon 100 101'
> > >>>> 'set lat 0 1'
> > >>>> 'define xdist = [(lon 99.7)/dlon]*[dx/2]'
> > >>>> 'define ydist = [(lat -1.02)/dlat]*[dy/2]'
> > >>! >> 'set z 5'
> > >>>> 'set t 1'
> > >> >> 'd ref'
> > >>>>
> > >>>> Below is my ctl file :
> > >>>>
> > >>>> DSET 1013.dat
> > >>>> TITLE RADAR
> > >>>> OPTIONS TEMPLATE LITTLE_ENDIAN
> > >>>> UNDEF -1000
> > >>>> XDEF 321 LINEAR 99.688120996 0.004492369
> > >>>> YDEF 321 LINEAR -1.083708891 0.004522556
> > >>>> ZDEF 39 LINEAR 1.0 0.5
> > >>>> TDEF 15 LINEAR 13:00Z10apr2004 4mn
> > >>>> VARS 2
> > >>>> ref 39 99 Reflectivity(dBZ)
> > >>>> vel 39 99 Doppler Velocity(m/s)
> > >>>> ENDVARS
> > >>>>
> > >>>>
> > >>>> Would you check my gs file, is there something that I have to
> revise??
> > >>>>
> > >>>> Thank you very much.
> > >>>>
> > &g! t;>>> Best regards,
> > >>>> wendi
> > >>>>
> > >>>>
> > >>>>
> > >>>> On Fri, Feb 1, 2013 at 10:34 AM, Jeff Duda <jeffduda319 at gmail.com
> >wrote:
> > >>>>
> > >>>>> These commands will help.
> > >>>>>
> > >>>>> 'define dx =
> 6.371e3*cos(lat*(3.14159/180))*cdiff(lon,x)*(3.14159/180)'
> > >>>>> 'define dy = 6.371e3*cdiff(lat,y)*(3.14159/180))'
> > >>>>>
> > >>>>> They define grid increments in terms of spatial distance rather
> than
> > >>>>> geographic distance. If you're trying to change the axes and tick
> marks,
> > >>>>> you'll have to define an origin and define your x and y distances
> based on
> > >>>>> that. For instance, if you set your lower left domain corner
> (latitude 0
> > >>>>! ;> and longitude 100), then you can define your coordinate
> distance s using
> > >>>>>
> > >>>>> 'define xdist = [(lon-100)/dlon]*[dx/2]'
> > >>>>> 'define ydist = [(lat-0)/dlat]*[dy/2]'
> > >>>>>
> > >>>>> I think this should work, but I haven't tested it myself, so I
> don't
> > >>>>> know. dlon and dlat are the step values from the XDEF and YDEF
> lines of
> > >>>>> the control file, respectively.
> > >>>>>
> > >>>>> Jeff Duda
> > >>>>>
> > >>>>> On Thu, Jan 31, 2013 at 7:02 AM, wendi harjupa <
> wendiharjupa at gmail.com
> > >>>>> > wrote:
> > >>>>>
> > >>>>>> Dear Sir/Madam
> > >>>>>>
> > >>>>>> I need help
> > >>>>>> I have problem with grads command,
> > >>>>>> I am not well understand wi! th command gr2XY,
> > >>>>>>
> > >>>>>> Actually I want to convert the lon 100 to 101, and lat 0 to 1 to
> > >>>>>> distance (km)
> > >>>>>> let think that lon 100 is 0 km, and lat 0 is 0 km,
> > >>>>>>
> > >>>>>> what command I can use to convert lon and lat to km?
> > >>>>>>
> > >>>>>> Thank you very much for your help
> > >>>>>>
> > >>>>>> best regards,
> > >>>>>> --
> > >>>>>> -------------
> > >>>>>> Wendi Harjupa. ST
> > >>>>>> Shimane University Graduate School of Engineering Sciences
> > >>>>>> Department of Electronic Control Systems
> > >>>>>> Remote Sensing Laboratory
> > >>>>>> s119447
> > ! >>>>>> Cellphone : +81-080-4268-6676
> > >> ;>>>> email : wendi at rslab.riko.shimane-u.ac.jp
>
> > >>>>>>
> > >>>>>> _______________________________________________
> > >>>>>> gradsusr mailing list
> > >>>>>> gradsusr at gradsusr.org
> > >>>>>> http://gradsusr.org/mailman/listinfo/gradsusr
> > >>>>>>
> > >>>>>>
> > >>>>>
> > >>>>>
> > >>>>> --
> > >>>>> Jeff Duda
> > >>>>> Graduate research assistant
> > >>>>> University of Oklahoma School of Meteorology
> > >>>>> Center for Analysis and Prediction of Storms
> > >>>>>
> > >>>>> _______________________________________________
> > >>>>> gradsusr mailing list
> > >>>>> gradsusr at gradsusr.org
> > >>>! ;>> http://gradsusr.org/mailman/listinfo/gradsusr
> > >>>>>
> > >>>>>
> > >>>>
> > >>>>
> > >>>> --
> > >>>> -------------
> > >>>> Wendi Harjupa. ST
> > >>>> Shimane University Graduate School of Engineering Sciences
> > >>>> Department of Electronic Control Systems
> > >>>> Remote Sensing Laboratory
> > >>>> s119447
> > >>>> Cellphone : +81-080-4268-6676
> > >>>> email : wendi at rslab.riko.shimane-u.ac.jp
>
> > >>>>
> > >>>> _______________________________________________
> > >>>> gradsusr mailing list
> > >>>> gradsusr at gradsusr.org
> > >>>> http://gradsusr.org/mailman/listinfo/gradsusr
> > >>>>
> > >>>>
> > >>>
> > >>>
> &! gt; >>> --
> > >>> Jeff Duda
> > >>> ; Graduate research assistant
>
> > >>> University of Oklahoma School of Meteorology
> > >>> Center for Analysis and Prediction of Storms
> > >>>
> > >>> _______________________________________________
> > >>> gradsusr mailing list
> > >>> gradsusr at gradsusr.org
> > >>> http://gradsusr.org/mailman/listinfo/gradsusr
> > >>>
> > >>>
> > >>
> > >>
> > >> --
> > >> -------------
> > >> Wendi Harjupa. ST
> > >> Shimane University Graduate School of Engineering Sciences
> > >> Department of Electronic Control Systems
> > >> Remote Sensing Laboratory
> > >> s119447
> > >> Cellphone : +81-080-4268-6676
> > >> email : wendi at rslab.riko.shimane-u.ac.jp
> > >>
> > >> _______________________________________________
> > >> gradsusr mailing! list
>
> > >> gradsusr at gradsusr.org
> > >> http://gradsusr.org/mailman/listinfo/gradsusr
> > >>
> > >>
> > >
> > >
> > > --
> > > Jeff Duda
> > > Graduate research assistant
> > > University of Oklahoma School of Meteorology
> > > Center for Analysis and Prediction of Storms
> > >
> > > _______________________________________________
> > > gradsusr mailing list
> > > gradsusr at gradsusr.org
> > > http://gradsusr.org/mailman/listinfo/gradsusr
> > >
> > >
> >
> >
> > --
> > -------------
> > Wendi Harjupa. ST
> > Shimane University Graduate School of Engineering Sciences
> > Department of Electronic Control Systems
> > Remote Sensing Laboratory
> > s119447
> > Cellphone : +81-080-4268-6676
> > email : wendi at rslab.riko.shimane-u.ac.jp
> > -------------- next part --------------
> > An HTML ! attachment was scrubbed...
> > URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130203/3be6f25a/attachment.html
> >
> > ------------------------------
>
> >
> > _______________________________________________
> > gradsusr mailing list
> > gradsusr at gradsusr.org
> > http://gradsusr.org/mailman/listinfo/gradsusr
> >
> >
> > End of gradsusr Digest, Vol 36, Issue 8
> > ***************************************
> *
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
--
Jeff Duda
Graduate research assistant
University of Oklahoma School of Meteorology
Center for Analysis and Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130203/d8f96332/attachment-0003.html
More information about the gradsusr
mailing list