Hi -
Ok, I see what you want. The script you had defines "per" and
"fft_uwnd" as separate variables, each on an axis in the T
direction, and then uses a graphical technique to plot them,
essentially a scatter plot with the first variable on the horizontal
axis and the second variable on the vertical axis so that visually
"fft_uwnd" is a function of "per". You want to define a frequency
axis and regrid the fft variable to that axis.
This should do it:
DEFINE AXIS/T/UNITS="your units describing the period"
per_axis = per
LET fft_per = FFT_UWND[gt=per_axis@ASN]
save/clobber/file=fft_period.nc fft_per
(You could give units or a title to the fft_per variable, see DEFINE
VARIABLE for how to do that.)
On 8/3/2012 10:23 AM, antonio avio
wrote:
Dear Ansley,
I do understand how this syntax works, but this is what i
mean:
netcdf fft_period {
dimensions:
FAXIS
= UNLIMITED ; // (378 currently)
LON41_41
= 1 ;
LAT38_38
= 1 ;
AX006
= 378 ;
variables:
double
FAXIS(FAXIS) ;
FAXIS:axis
= "T" ;
double
PER(FAXIS) ;
PER:missing_value
= -1.e+34 ;
PER:_FillValue
= -1.e+34 ;
PER:long_name
= "1./A" ;
double
LON41_41(LON41_41) ;
LON41_41:units
= "degrees_east" ;
LON41_41:long_name
= "Longitude" ;
LON41_41:axis
= "X" ;
LON41_41:modulo
= 360. ;
LON41_41:point_spacing
= "even" ;
LON41_41:standard_name
= "longitude" ;
double
LAT38_38(LAT38_38) ;
LAT38_38:units
= "degrees_north" ;
LAT38_38:long_name
= "Latitude" ;
LAT38_38:axis
= "Y" ;
LAT38_38:point_spacing
= "even" ;
LAT38_38:standard_name
= "latitude" ;
double
AX006(AX006) ;
AX006:units
= "CYC/MONTHS" ;
AX006:point_spacing
= "even" ;
AX006:axis
= "T" ;
AX006:standard_name
= "time" ;
double
FFT_UWND(AX006, LAT38_38, LON41_41) ;
FFT_UWND:missing_value
= -1.e+34 ;
FFT_UWND:_FillValue
= -1.e+34 ;
FFT_UWND:long_name
= "Amplitude Spectrum" ;
FFT_UWND:history
= "From uwnd.mon.mean" ;
You can see that the "PER" separated from
"FFT_UWND. Meanwhile the AX006 is still in FFT_UWND and with
frequency unit thats why the X axis unit still in
frequency. What i am still struggling to produce and really
want is how to save the file with this information:
double FFT_UWND(PER, LAT38_38, LON41_41) ;
Thus when i want to compile this NC file with other
computational language will be much easier.
Sorry for this inconvenience.
Best,
Antonio
On Fri, Aug 3, 2012 at 6:40 PM, Ansley
Manke <ansley.b.manke@xxxxxxxx>
wrote:
Hi Antonio,
I'd like to suggest you work on learning some basic Ferret
syntax, so that you can figure this stuff out yourself.
Try,
yes? go tutorial
and read what's on the screen as the script runs. Next,
you can get a good start on understanding the syntax if
you read the first chapter of the Users Guide on our
Documentation pages. http://ferret.pmel.noaa.gov/Ferret/documentation
Now, look up the LIST command to see what the error
message is talking about. There is a /CLOBBER qualifier
which is explained there.
When you have a script and you want to debug what's
happening in it, what I would do is to run it as is, and
at different points in the script, put in some LIST
commands, to list numbers to the screen in your ferret
session:
PLOT/VS/LINE/HLIMITS=0:32:2/TITLE="Amplitude
Spectrum"/SET_UP per[l=1:`FFT_nf`], fft_uwnd
...
PPL PLOT
list/L=1:5 per, fft_uwnd
pause
! now list all the data
list per, fft_uwnd
pause
I'm not sure how of the variable fft_uwnd was defined, or
why the author of your original script has listed the
variables to plot as per[l=1:`FFT_nf`], fft_uwnd, with a
range of L given just on the variable "per" on the command
line. If the plot is correct, then saving the variables
store the same numbers to the file.
Ansley
On 8/2/2012 5:59 PM, antonio avio wrote:
Hi,
Thanks for the correction but it still not
working correctly, If I use your first suggestion,
the compilation
works well but the results are wrong. The axis
still in frequency unit and the values are not
change (the same as
in fft frequency unit). As i mentioned before,
I'd like to save the fft and phase from spectral
analysis which have period unit in x axis.
But if i use the second suggestion,
i got this error:
let AOUT = fft_uwnd
**ERROR: invalid command: /CLOBBER not
specified and file exists: fft_period.nc
Command file, command group, or REPEAT
execution aborted
Thanks a lot,
Antonio
On Fri, Aug 3, 2012 at
2:31 AM, Ansley Manke <ansley.b.manke@xxxxxxxx>
wrote:
Hi -
My apologies. I made an editing error like I
think you had done, originally!
You have commands which define the FFT
variables, but the script you had is making
a plot so it lists pairs of variables to
plot. It has defined variables including
"per", "fft_uwnd", and "FFT_uwndfftp"
So all you need is
!Save fft period unit
!Save phase in period unit
Or if you want to rename variables you could
do this, but watch out about variable names,
there is already a variable called A in the
script, so if you do a "LET A = "
definition, you'd redefine that existing
variable and ruin the calculation.
!Save fft period unit
let AOUT = fft_uwnd
!Save phase in period unit
let BOUT = FFT_uwndfftp
On 8/2/2012 3:16 PM, antonio avio
wrote:
Hallo,
Thanks Ansley for the reply,
The main goal is to save the
fft and phase from spectral
analysis which have period unit in
x axis.
Yes, I also did the same thing,
but i still got the error message,
After compiling i got this
error:
**ERROR: command syntax:
per[l=1:378], fft_uwnd
Definition
contains multiple expressions
DEFINE VARIABLE A =
per[l=1:378], fft_uwnd
Command file, command
group, or REPEAT execution
aborted
Thanks for the helps,
Antonio
On Thu,
Aug 2, 2012 at 9:36 PM, Ansley
Manke <ansley.b.manke@xxxxxxxx>
wrote:
Hi
You are using "SET_UP per"
as if it's a variable name.
The error message is telling
you that variable names in
Ferret cannot have a space
in them.
Do you mean to say this?
let A =
per[l=1:`FFT_nf`],
fft_uwnd
On 8/2/2012 10:58
AM, antonio avio
wrote:
Hallo,
I wonder why I
got this error when
i wanted to save the
results of FFT
analysis (period
unit not frequency)
in different nc
files:
!Save fft in
period unit
let A =
SET_UP
per[l=1:`FFT_nf`],
fft_uwnd
!->
DEFINE VARIABLE
A = SET_UP
per[l=1:378],
fft_uwnd
**ERROR:
command syntax:
SET_UP
per[l=1:378],
fft_uwnd
SET_UP before
per[l=1:378] is
illegal
DEFINE
VARIABLE A =
SET_UP
per[l=1:378],
fft_uwnd
Command
file, command
group, or REPEAT
execution
aborted
Here is my
command:
[SNIP]
!converting to
Period
! Get the
frequency
increment used in
the FFT.
LET
FFT_nf =
`fft_uwnd,return=lend`
LET
FFT_nyquist = 0.5
LET
FFT_freq1 =
FFT_nyquist/
FFT_nf
! Define a
frequency axis.
DEFINE
AXIS/T=`FFT_freq1`:`FFT_nyquist`:`FFT_freq1`
FAXIS
DEFINE
GRID/T=FAXIS
gfftfreq
LET a =
T[g=gfftfreq]
! Define the
period from the
frequency axis.
LET per =
1./a
! Plot period
vs FFT Amplitudes
showing the first
24 months where
most of the energy
is.
! The PPL
commands clean up
the appearance of
the plot.
SET VIEW ur
PLOT/VS/LINE/HLIMITS=0:32:2/TITLE="Amplitude
Spectrum"/SET_UP
per[l=1:`FFT_nf`],
fft_uwnd
PPL XFOR
(I2)
PPL XLAB
Period,
months/cycle
PPL YLAB
PPL PLOT
!****************************************************************************************************
! Compute and
plot the phase
using fftp.
LET
FFT_uwndfftp =
fftp(fft_u[l=1:757])
SET
VARIABLE/TITLE="FFT
Phase"/UNITS="deg"
FFT_uwndfftp
SET VIEW
ll
PLOT
FFT_uwndfftp
SET VIEW
lr
PLOT/VS/LINE/HLIMITS=0:32:2/TITLE="FFT
Phase"/SET_UP
per[l=1:`FFT_nf`],FFT_uwndfftp
PPL XFOR
(I2)
PPL XLAB
Period,
months/cycle
PPL YLAB
Deg
PPL PLOT
!Save fft
period unit
let A =
SET_UP
per[l=1:`FFT_nf`],
fft_uwnd
!Save phase
in period unit
let B =
SET_UP
per[l=1:`FFT_nf`],
FFT_uwndfftp
!**********************************************************************************
Thanks for your
help.
Antonio.
|