[Thread Prev][Thread Next][Index]

[ferret_users] Aspect, bad values using poly_vector.jnl



Dear Ferret users,

I hope this email finds you well.

I am writing regarding some vector plots. I am using PyFerret v7.63 on Linux Ubuntu (via miniconda) but I have the same issues with PyFerret v7.62 and ferret v6.71.

I am drawing an hovmuller vector plot (x-t plot) of the wind stress anomalies along the equator for 2021, overlaying SST anomalies.
I am pretty happy with the result of the command VECTOR/OV without specifying /ASPECT, because the time axis does not have a spatial scale. However, I prefer the look of the arrows drawn by the "go poly_vector.jnl" script, associated with POLYGON/OVER.

I encountered 2 problems using the poly_vector.jnl script:

1) Using go poly_vector.jnl, my first problem was the difference in the axis scaling (y_scale/x_scale) between the VECTOR/OV plot and the poly_vector.jnl script.
---> I thus modified the poly_vector scrip.jnl (see script attached) to include the possibility to adjust the direction of the vectors just like with /ASPECT in the VECTOR/OV plot.
I created a 7th input argument, that corrects the direction of the arrows.
The script works with or without specifying the 7th argument and mimics the arrows drawn with the command VECTOR/OV (I do not know why I had to scale with sqrt(2), see below).

let vect_aspect = $7"-1."

! Compute the vector direction on the plot
let vect_rotation= if vect_aspect lt 0 then plt_y_per_inch/plt_x_per_inch else vect_aspect*(plt_x_inch_span/plt_y_inch_span)*(2)^0.5
let pi = 4*atan(1)
let vect_dir = atan2(vect_rotation*vect_y_comp/plt_y_per_inch, vect_x_comp/plt_x_per_inch)


2) My second problem was linked to bad values. I do not want to plot vectors if the arrows are too small. I thus masked the wind stress components using a simple if loop.
It works fine until I add a value to color the arrows.
*** POLYGON/OVER/NOLABEL/KEY/NOAXES/LINE PLT_X_ARROW, PLT_Y_A

Attachment: poly_vectors2.jnl
Description: Binary data

Attachment: My_plot_shifted.png
Description: PNG image

Attachment: My_plot_corrected.png
Description: PNG image

* 
*  keep_good.F in 6D
* 
*  Serena Illig
*  June 2022
* 
*  Remove the bad values by shifting the data !!!
* 
 
SUBROUTINE keep_good_init(id)
 
INCLUDE 'EF_Util.cmn'
 
INTEGER id, arg
*
* **********************************************************************
*                                            USER CONFIGURABLE PORTION |
*                                                                      |
*
CALL ef_set_desc(id,'Keep good data and remove bad values')
*
CALL ef_set_num_args(id, 1)
CALL ef_set_has_vari_args(id, NO)
CALL ef_set_axis_inheritance_6d(id, NORMAL, 
.     IMPLIED_BY_ARGS, IMPLIED_BY_ARGS, IMPLIED_BY_ARGS,
.     IMPLIED_BY_ARGS, IMPLIED_BY_ARGS)
CALL ef_set_piecemeal_ok_6d(id, YES, YES, YES, YES, YES, YES)
*
arg = 1
CALL ef_set_arg_name(id, arg, 'A')
CALL ef_set_arg_desc(id, arg, 'Field to be Processed')
CALL ef_set_axis_influence_6d(id, arg, YES, YES, YES, YES, YES, YES)
*
*                                                                      ^
*                                                                      |
*                                            USER CONFIGURABLE PORTION |
* **********************************************************************
 
RETURN 
END
 
 
* 
*  In this subroutine we compute the result
* 
SUBROUTINE keep_good_compute(id, arg_1, result)
 
IMPLICIT none
 
INCLUDE 'EF_Util.cmn'
INCLUDE 'EF_mem_subsc.cmn'
 
INTEGER id, arg
 
REAL bad_flag(EF_MAX_ARGS), bad_flag_result
REAL arg_1(mem1lox:mem1hix, mem1loy:mem1hiy, mem1loz:mem1hiz,
.           mem1lot:mem1hit, mem1loe:mem1hie, mem1lof:mem1hif)
 
REAL result(memreslox:memreshix, memresloy:memreshiy,
.            memresloz:memreshiz, memreslot:memreshit,
.            memresloe:memreshie, memreslof:memreshif)
*
* After initialization, the 'res_' arrays contain indexing information 
* for the result axes.  The 'arg_' arrays will contain the indexing 
* information for each variable's axes. 
*
INTEGER res_lo_ss(6), res_hi_ss(6), res_incr(6)
INTEGER arg_lo_ss(6,EF_MAX_ARGS), arg_hi_ss(6,EF_MAX_ARGS),
.     arg_incr(6,EF_MAX_ARGS)
*
* **********************************************************************
*                                            USER CONFIGURABLE PORTION |
*                                                                      |
*                                                                      V
INTEGER i,j,k,l,m,n
INTEGER i1,j1,k1,l1,m1,n1   
*
CALL ef_get_res_subscripts_6d(id, res_lo_ss, res_hi_ss, res_incr)
CALL ef_get_arg_subscripts_6d(id, arg_lo_ss, arg_hi_ss, arg_incr)
CALL ef_get_bad_flags(id, bad_flag, bad_flag_result)
*
DO 105 n=res_lo_ss(F_AXIS), res_hi_ss(F_AXIS)
DO 104 m=res_lo_ss(E_AXIS), res_hi_ss(E_AXIS) 
DO 103 l=res_lo_ss(T_AXIS), res_hi_ss(T_AXIS)
DO 102 k=res_lo_ss(Z_AXIS), res_hi_ss(Z_AXIS)       
DO 101 j=res_lo_ss(Y_AXIS), res_hi_ss(Y_AXIS)
DO 100 i=res_lo_ss(X_AXIS), res_hi_ss(X_AXIS) 
result(i,j,k,l,m,n)=bad_flag_result
100  ENDDO
101  ENDDO
102  ENDDO
103  ENDDO
104  ENDDO
105  ENDDO
 
DO 205 n1=arg_lo_ss(F_AXIS,ARG1), arg_hi_ss(F_AXIS,ARG1)
DO 204 m1=arg_lo_ss(E_AXIS,ARG1), arg_hi_ss(E_AXIS,ARG1)  
i=res_lo_ss(X_AXIS)
j=res_lo_ss(Y_AXIS)
k=res_lo_ss(Z_AXIS)
l=res_lo_ss(T_AXIS)     
DO 203 l1=arg_lo_ss(T_AXIS,ARG1), arg_hi_ss(T_AXIS,ARG1)
DO 202 k1=arg_lo_ss(Z_AXIS,ARG1), arg_hi_ss(Z_AXIS,ARG1)       
DO 201 j1=arg_lo_ss(Y_AXIS,ARG1), arg_hi_ss(Y_AXIS,ARG1)
DO 200 i1=arg_lo_ss(X_AXIS,ARG1), arg_hi_ss(X_AXIS,ARG1) 
if (arg_1(i1,j1,k1,l1,m1,n1).ne.bad_flag(1)) then
result(i,j,k,l,m1,n1)=arg_1(i1,j1,k1,l1,m1,n1)
if (i.ne.res_hi_ss(X_AXIS)) then
i=i+1
else
i=res_lo_ss(X_AXIS)
if (j.ne.res_hi_ss(Y_AXIS)) then
j=j+1
else
j=res_lo_ss(Y_AXIS)
if (k.ne.res_hi_ss(Z_AXIS)) then
k=k+1
else
k=res_lo_ss(Z_AXIS)
l=l+1
endif                               
endif          
endif
endif
*            
200  ENDDO
201  ENDDO
202  ENDDO
203  ENDDO
204  ENDDO
205  ENDDO
*                                                                      ^
*                                                                      |
*                                            USER CONFIGURABLE PORTION |
* **********************************************************************
 
RETURN 
END

[Thread Prev][Thread Next][Index]