[gradsusr] Printing values to a text file

Jan Ising jising at aggies.ncat.edu
Wed Mar 11 14:26:06 EDT 2020


Hello Jeff,

    Thank you for your reply, I apologize for my delayed response, I became
very busy suddenly with unrelated tasks this week. I have been working
multiple angles at this and will try what you had suggested next. I have
discovered a couple more routes I can go after this but I want to try to
avoid a manual CAPE calculation if possible, especially with GrADS. Should
it come down to it I will reach out again with more details.
    On a side note, could you please explain a little bit more on the
commands "ugrdprs" and "vgrdprs"? I have not worked with these before.



-Thanks,
Jon

 _______________________________________________
Message: 2
Date: Sat, 7 Mar 2020 12:18:59 -0700
From: Jeff Duda <jeffduda319 at gmail.com>
To: GrADS Users Forum <gradsusr at gradsusr.org>
Subject: Re: [gradsusr] gradsusr Digest, Vol 121, Issue 6
Message-ID:
        <CAAig09CqJW7Kv=NZ1Y4VVTcE+W35n_HkfmkbDyFH7Yi_1=e+Bw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Jon,
Based on what you are telling me, I believe I did understand what you
asked, and my original suggestion remains a viable option. In order to get
the numerical values of a grid printed out in ASCII format, you need to
display one of the fields in your data file. The code snippet you attached
in your original email does not have that line anywhere. Because of that
omission, you are getting output that differs from your expectations.

But, given your additional information, this may turn out to be much easier
than it first sounded:

If you do have the fundamental components of BRN (CAPE and shear
basically), and especially if you already have an array of CAPE values
(thank goodness, because computing that manually from the T/qv grid would
be no fun at all), you can calculate BRN directly in grads in one single
command (or two or three, depending on how you want to break up the
calculation):

'define shear = mag(ugrdprs(lev=*lev1*)-ugrdprs(lev=*lev2*),vgrdprs(lev=
*lev1*)-vgrdprs(lev=*lev2*)'
'define BRN = CAPE / pow(shear,2)'
'display BRN'

QED.

Try that out and see what works. If you're missing CAPE in your data file,
then we can talk more about your originally suggested method.

Jeff Duda

On Sat, Mar 7, 2020 at 11:56 AM Jan Ising <jising at aggies.ncat.edu> wrote:

> Hello Jeff,
>     Thank you for your response however, I believe there was some
> confusion. Let me explain with more detail. I am trying to calculate the
> Bulk Richardson Number (my data file (a .ctl file) does not have this
> predefined), to do so I need to calculate each individual component of the
> BRN from the different variables in my file (MUCAPE, Wind, etc...)
> separately for each gridpoint, since GrADS does not allow for 2D arrays
> that the user makes (say for instance in a script). This all works fine
and
> the values are outputted to my .txt. file, but only as 1 column with x
rows
> (where x is the number of grid points there are in my file). But I need it
> to be in rows AND columns so that I can use the new grid, made only of
> numbers (i.e the text file) and continue working with it in MATLAB (say
for
> example plotting it). Sorry if this was unclear before, I tried to
simplify
> it so my question is better understood, but it seems I may have
> achieved the opposite.
>
>
>> ----------------------------------------------------------------------
>>
>> Date: Fri, 6 Mar 2020 12:30:35 -0700
>> From: Jeff Duda <jeffduda319 at gmail.com>
>> To: GrADS Users Forum <gradsusr at gradsusr.org>
>> Subject: Re: [gradsusr] Printing values to a text file
>> Message-ID:1
>>         <
>> CAAig09DcTUY1j+k7hNDGMpHr1JhuS4D5k_3PEiVSG20aPV17cw at mail.gmail.com>
>> Content-Type: text/plain; charset="utf-8"
>>
>> I think the problem is that you're not displaying a data field in your
>> code. It looks like you're telling Grads just to spit out a sequence of
>> integers. You don't need Grads for that. Also, the gxout print and
prnopts
>> probably aren't meant to be used for that. You could easily just do
>>
>> a = 1
>> while (a < 400)
>>  say a
>>  a = a + 1
>> endwhile
>>
>> Then copy your screen to a text file, or just use grads -H [*logfile*] to
>> tell Grads to log commands + output to *logfile*
>>
>> Jeff Duda
>>
>> On Fri, Mar 6, 2020 at 11:47 AM Jan Ising <jising at aggies.ncat.edu> wrote:
>>
>> > Hello,
>> >
>> > How would I display multiple values per line in a .txt file from a
>> > single-valued changing variable (see code)? Based on the code below it
>> is
>> > currently displaying 1 value per line instead of 200 values per line:
>> >
>> >  'set gxout print'
>> > 'set prnopts %f 200 1'
>> > a = 0
>> >
>> > while (a < 400)
>> > a = a + 1
>> > dummy = write(test_output, a, append)
>> > endwhile
>> >
>> >
>> > Result is:
>> > 1
>> > 2
>> > 3
>> > 4
>> > 5
>> > ...
>> >
>> > Instead of:
>> > 1 2 3 4 5
>> > 6 7 8 9 10
>> >
>> > any help would be greatly appreciated
>> >
>> > -Thanks,
>> > Jon
>> > _______________________________________________
>> > gradsusr mailing list
>> > gradsusr at gradsusr.org
>> > http://gradsusr.org/mailman/listinfo/gradsusr
>> >
>>
>>
>> --
>> Jeff Duda, Research Scientist
>> University of Colorado Boulder
>> Cooperative Institute for Research in Environmental Sciences
>> NOAA/OAR/ESRL/Global Systems Division
>> Boulder, CO
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>>
http://gradsusr.org/pipermail/gradsusr/attachments/20200306/31eab672/attachment-0001.html
>> >
>>
>> ------------------------------
>>
>>
>
>
> -Thanks,
> Jon
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>


--
Jeff Duda, Research Scientist
University of Colorado Boulder
Cooperative Institute for Research in Environmental Sciences
NOAA/OAR/ESRL/Global Systems Division
Boulder, CO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
http://gradsusr.org/pipermail/gradsusr/attachments/20200307/f04f89ed/attachment-0001.html
>

------------------------------

Subject: Digest Footer

_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr


------------------------------

End of gradsusr Digest, Vol 121, Issue 7
****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20200311/589d636e/attachment.html>


More information about the gradsusr mailing list