@@ -80,6 +80,11 @@ struct PSVELO_CTRL {
80
80
bool active ;
81
81
struct GMT_FILL fill ;
82
82
} G ;
83
+ struct SVELO_I { /* -I[<intensity>] */
84
+ bool active ;
85
+ unsigned int mode ; /* 0 if constant, 1 if read from file */
86
+ double value ;
87
+ } I ;
83
88
struct PSVELO_L { /* -L[<pen>] */
84
89
bool active ;
85
90
bool error_pen ;
@@ -650,7 +655,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
650
655
const char * name = gmt_show_name_and_purpose (API , THIS_MODULE_LIB , THIS_MODULE_CLASSIC_NAME , THIS_MODULE_PURPOSE );
651
656
if (level == GMT_MODULE_PURPOSE ) return (GMT_NOERROR );
652
657
GMT_Message (API , GMT_TIME_NONE , "usage: %s [<table>] %s %s [-A<vecpar>] [%s]\n" , name , GMT_J_OPT , GMT_Rgeo_OPT , GMT_B_OPT );
653
- GMT_Message (API , GMT_TIME_NONE , "\t[-C<cpt>] [-D<sigscale>] [-G<fill>] %s[-L[<pen>][+c[f|l]]] [-N] %s%s[-S<symbol><args>[+f<font>]]\n" , API -> K_OPT , API -> O_OPT , API -> P_OPT );
658
+ GMT_Message (API , GMT_TIME_NONE , "\t[-C<cpt>] [-D<sigscale>] [-G<fill>] [-I[<intens>]] %s[-L[<pen>][+c[f|l]]] [-N] %s%s[-S<symbol><args>[+f<font>]]\n" , API -> K_OPT , API -> O_OPT , API -> P_OPT );
654
659
GMT_Message (API , GMT_TIME_NONE , "\t[%s] [-V] [-W[<pen>][+c[f|l]]] [%s] [%s]\n" , GMT_U_OPT , GMT_X_OPT , GMT_Y_OPT );
655
660
GMT_Message (API , GMT_TIME_NONE , "\t[-Z[m|e|n|u][+e] %s[%s] [%s] [%s]\n\t[%s] [%s]\n\t[%s] [%s] [%s] [%s]\n\n" , API -> c_OPT , GMT_di_OPT , GMT_e_OPT , GMT_h_OPT , GMT_i_OPT , GMT_p_OPT , GMT_qi_OPT , GMT_t_OPT , GMT_colon_OPT , GMT_PAR_OPT );
656
661
@@ -668,6 +673,8 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
668
673
GMT_Message (API , GMT_TIME_NONE , "\t-E Set color used for uncertainty ellipses and wedges [no fill].\n" );
669
674
GMT_Message (API , GMT_TIME_NONE , "\t For other coloring options, see -L and -Z.\n" );
670
675
gmt_fill_syntax (API -> GMT , 'G' , NULL , "Specify color or pattern for symbol fill [no fill]." );
676
+ GMT_Message (API , GMT_TIME_NONE , "\t-I Use the intensity to modulate the symbol fill color (requires -C or -G).\n" );
677
+ GMT_Message (API , GMT_TIME_NONE , "\t If no intensity is given we expect it to follow the required columns in the data record.\n" );
671
678
GMT_Option (API , "K" );
672
679
GMT_Message (API , GMT_TIME_NONE , "\t-L Draw line or symbol outline using the current pen (see -W).\n" );
673
680
GMT_Message (API , GMT_TIME_NONE , "\t Optionally, append separate pen for error outlines [Same as -W].\n" );
@@ -765,6 +772,13 @@ static int parse (struct GMT_CTRL *GMT, struct PSVELO_CTRL *Ctrl, struct GMT_OPT
765
772
n_errors ++ ;
766
773
}
767
774
break ;
775
+ case 'I' : /* Adjust symbol color via intensity */
776
+ Ctrl -> I .active = true;
777
+ if (opt -> arg [0 ])
778
+ Ctrl -> I .value = atof (opt -> arg );
779
+ else
780
+ Ctrl -> I .mode = 1 ;
781
+ break ;
768
782
case 'L' : /* Draw the outline */
769
783
Ctrl -> L .active = true;
770
784
if (opt -> arg [0 ]) {
@@ -882,10 +896,14 @@ static int parse (struct GMT_CTRL *GMT, struct PSVELO_CTRL *Ctrl, struct GMT_OPT
882
896
#define bailout (code ) {gmt_M_free_options (mode); return (code);}
883
897
#define Return (code ) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}
884
898
885
- GMT_LOCAL void psvelo_set_colorfill (struct GMT_CTRL * GMT , struct PSVELO_CTRL * Ctrl , struct GMT_PALETTE * P , double value ) {
899
+ GMT_LOCAL void psvelo_set_colorfill (struct GMT_CTRL * GMT , struct PSVELO_CTRL * Ctrl , struct GMT_PALETTE * P , double value , double ival ) {
886
900
/* Called if -C was given. Selects and updates color fills and possibly pen colors */
887
901
struct GMT_FILL * F = (Ctrl -> Z .item == PSVELO_G_FILL ) ? & Ctrl -> G .fill : & Ctrl -> E .fill ;
888
902
gmt_get_fill_from_z (GMT , P , value , F );
903
+ if (Ctrl -> I .active ) {
904
+ gmt_illuminate (GMT , ival , F -> rgb );
905
+ GMT_Report (GMT -> parent , GMT_MSG_DEBUG , "Illumination value used is %h\n" , ival );
906
+ }
889
907
if (Ctrl -> L .pen .cptmode & 1 ) { /* Also change error pen color via CPT */
890
908
gmt_M_rgb_copy (Ctrl -> L .pen .rgb , F -> rgb );
891
909
gmt_setpen (GMT , & Ctrl -> L .pen );
@@ -901,13 +919,14 @@ GMT_LOCAL void psvelo_set_colorfill (struct GMT_CTRL *GMT, struct PSVELO_CTRL *C
901
919
EXTERN_MSC int GMT_psvelo (void * V_API , int mode , void * args ) {
902
920
int ix = 0 , iy = 1 , n_rec = 0 , justify ;
903
921
int plot_ellipse = true, plot_vector = true, error = false;
922
+ unsigned int icol = 0 ;
904
923
bool set_g_fill , set_e_fill ;
905
924
906
925
double plot_x , plot_y , vxy [2 ], plot_vx , plot_vy , length , s , dim [PSL_MAX_DIMS ];
907
926
double eps1 = 0.0 , eps2 = 0.0 , spin = 0.0 , spinsig = 0.0 , theta = 0.0 , * in = NULL ;
908
927
double direction = 0 , small_axis = 0 , great_axis = 0 , sigma_x , sigma_y , corr_xy ;
909
928
double t11 = 1.0 , t12 = 0.0 , t21 = 0.0 , t22 = 1.0 , hl , hw , vw , ssize , headpen_width = 0.0 ;
910
- double z_val , e_val , value ;
929
+ double z_val , e_val , value , i_value ;
911
930
912
931
char * station_name = NULL ;
913
932
@@ -944,6 +963,11 @@ EXTERN_MSC int GMT_psvelo (void *V_API, int mode, void *args) {
944
963
if (Ctrl -> Z .item == PSVELO_G_FILL ) set_g_fill = true; /* Since we will set it via CPT lookup */
945
964
if (Ctrl -> Z .item == PSVELO_E_FILL ) set_e_fill = true; /* Since we will set it via CPT lookup */
946
965
}
966
+ else if (Ctrl -> I .active && Ctrl -> I .mode == 0 ) { /* Constant illumination with constant intensity can be done before data loop */
967
+ gmt_illuminate (GMT , Ctrl -> I .value , Ctrl -> E .fill .rgb );
968
+ gmt_illuminate (GMT , Ctrl -> I .value , Ctrl -> G .fill .rgb );
969
+ }
970
+ i_value = Ctrl -> I .value ; /* May be replaced in the loop if no intensity was given */
947
971
if (!Ctrl -> L .error_pen ) /* Duplicate -W to -L */
948
972
gmt_M_memcpy (& Ctrl -> L .pen , & Ctrl -> W .pen , 1 , struct GMT_PEN );
949
973
@@ -966,6 +990,11 @@ EXTERN_MSC int GMT_psvelo (void *V_API, int mode, void *args) {
966
990
967
991
ix = (GMT -> current .setting .io_lonlat_toggle [0 ]); iy = 1 - ix ;
968
992
993
+ if (Ctrl -> I .mode ) { /* Read intensity from data file */
994
+ Ctrl -> S .n_cols ++ ; /* One more data column required */
995
+ icol = Ctrl -> S .n_cols - 1 ; /* Column id for intensity */
996
+ gmt_set_column_type (GMT , GMT_IN , icol , GMT_IS_FLOAT );
997
+ }
969
998
if (Ctrl -> Z .mode == PSVELO_V_USER ) Ctrl -> S .n_cols ++ ; /* Need to read one extra column */
970
999
971
1000
GMT_Set_Columns (API , GMT_IN , Ctrl -> S .n_cols , GMT_COL_FIX );
@@ -1026,7 +1055,7 @@ EXTERN_MSC int GMT_psvelo (void *V_API, int mode, void *args) {
1026
1055
case PSVELO_V_MAG : z_val = hypot (vxy [0 ], vxy [1 ]); e_val = hypot (sigma_x , sigma_y ); break ;
1027
1056
case PSVELO_V_EAST : z_val = vxy [0 ]; e_val = sigma_x ; break ;
1028
1057
case PSVELO_V_NORTH : z_val = vxy [1 ]; e_val = sigma_y ; break ;
1029
- case PSVELO_V_USER : z_val = e_val = in [7 ]; break ;
1058
+ case PSVELO_V_USER : z_val = e_val = in [Ctrl -> S . n_cols - 1 ]; break ;
1030
1059
}
1031
1060
}
1032
1061
/* rescale uncertainties if necessary */
@@ -1055,7 +1084,7 @@ EXTERN_MSC int GMT_psvelo (void *V_API, int mode, void *args) {
1055
1084
case PSVELO_V_MAG : z_val = hypot (vxy [0 ], vxy [1 ]); e_val = hypot (great_axis , small_axis ); break ;
1056
1085
case PSVELO_V_EAST : z_val = vxy [0 ]; e_val = great_axis ; break ;
1057
1086
case PSVELO_V_NORTH : z_val = vxy [1 ]; e_val = small_axis ; break ;
1058
- case PSVELO_V_USER : z_val = e_val = in [7 ]; break ;
1087
+ case PSVELO_V_USER : z_val = e_val = in [Ctrl -> S . n_cols - 1 ]; break ;
1059
1088
}
1060
1089
}
1061
1090
if (fabs (great_axis ) < EPSIL && fabs (small_axis ) < EPSIL )
@@ -1078,7 +1107,7 @@ EXTERN_MSC int GMT_psvelo (void *V_API, int mode, void *args) {
1078
1107
if (Ctrl -> C .active ) {
1079
1108
switch (Ctrl -> Z .mode ) {
1080
1109
case PSVELO_V_MAG : z_val = spin ; e_val = spinsig ; break ;
1081
- case PSVELO_V_USER : z_val = e_val = in [4 ]; break ;
1110
+ case PSVELO_V_USER : z_val = e_val = in [Ctrl -> S . n_cols - 1 ]; break ;
1082
1111
}
1083
1112
}
1084
1113
if (Ctrl -> D .active ) spinsig = spinsig * Ctrl -> D .scale ;
@@ -1092,8 +1121,9 @@ EXTERN_MSC int GMT_psvelo (void *V_API, int mode, void *args) {
1092
1121
gmt_geo_to_xy (GMT , in [GMT_X ], in [GMT_Y ], & plot_x , & plot_y );
1093
1122
1094
1123
value = (Ctrl -> Z .item == PSVELO_E_FILL ) ? e_val : z_val ; /* Select which value for color lookup - if active */
1124
+ if (Ctrl -> I .mode ) i_value = in [icol ];
1095
1125
if (Ctrl -> C .active ) { /* Possibly update E or G fills based on value, then set in PS */
1096
- psvelo_set_colorfill (GMT , Ctrl , CPT , value );
1126
+ psvelo_set_colorfill (GMT , Ctrl , CPT , value , i_value );
1097
1127
gmt_init_vector_param (GMT , & Ctrl -> A .S , true, Ctrl -> W .active , & Ctrl -> W .pen , Ctrl -> G .active , & Ctrl -> G .fill );
1098
1128
}
1099
1129
0 commit comments