spedas / bleeding_edge

IDL-based Space Physics Environment Data Analysis Software (bleeding edge)
http://www.spedas.org
Other
7 stars 0 forks source link

thm_allplots failing since Oct 15 #140

Closed jameswilburlewis closed 1 month ago

jameswilburlewis commented 6 months ago

This message has been showing up in the logs since October 15 2023 (which would have been processing data for Sept 15). I think it's not actually updating any plots:

ambrosia-overplots [52] tail ALLPLOTS_231211_2844095
   /disks/socware/thmsoc_dp_current/idl/projects/themis/ground/thm_gmag_stack
  plot_intervals.pro
% Illegal variable attribute: X.
% Error occurred at: THM_GMAG_STACKPLOT_INTERVALS  231
   /disks/socware/thmsoc_dp_current/idl/projects/themis/ground/thm_gmag_stack
  plot_intervals.pro
%                    THM_ALLPLOTS       51
   /disks/socware/thmsoc_dp_current/idl/thmsoc/summary_plots/thm_allplots.pro
%                    $MAIN$          
% Execution halted at: $MAIN$          
jameswilburlewis commented 6 months ago

It seems to be failing if there are no low latitude stations to plot. I'm not sure why thm_allplots is failing, but the normal stackplot processing seems to work OK for the same dates....maybe the error is being caught so it goes ahead with the rest of the plots?

jameswilburlewis commented 6 months ago

I made some changes in thm_gmag_stackplot_intervals that may have fixed the problem. Leaving this issue open until we decide if any changes to other routines/scripts are needed, or if the bug fix calls for any reprocessing. Here's the diff for my changes:

--- thm_gmag_stackplot_intervals.pro    (revision 29361)
+++ thm_gmag_stackplot_intervals.pro    (revision 32327)
@@ -127,6 +127,7 @@

   ;  timespan, date, duration
   timespan, start_times[k], dhr[k], /hour
+  stations=['filler']

   ;________________________________________________________________________________________________
   ;this section is in place to make sure that we are only looking at data in the time range specified,
@@ -188,10 +189,12 @@
      ;hi_lat_lon_index = reverse(sort(hi_lon))
      hi_lat_lon_index = sort(hi_lon)
      hi_stat = hi_stat[hi_lat_lon_index]
+     skip_hi = 0  ; set a flag to be checked in the loop below
   Endif Else Begin
      hi_stat = -1
      hi_lon = -1
      hi_lat_lon_index = -1
+     skip_hi = 1  ; set a flag to be checked in the loop below
   Endelse
   If (lo_index[0] Ne -1) Then Begin
      lo_stat = stations[lo_index]
@@ -198,10 +201,12 @@
      lo_lon = lons[lo_index]
      lo_lat_lon_index = sort(lo_lon)
      lo_stat = lo_stat[lo_lat_lon_index]
+     skip_lo = 0  ; set a flag to be checked in the loop below
   Endif Else Begin
      lo_stat = -1
      lo_lon = -1
      lo_lat_lon_index = -1
+     skip_lo = 1  ; set a flag to be checked in the loop below
   Endelse

   ;________________________________________________________________________________________________
@@ -210,10 +215,26 @@

   for w=a,b do begin

-    if w eq 0 then stations = hi_stat else stations = lo_stat
+    ; Do we need to skip this latitude range?
+    ; 
+    ; The original code assigned hi_stat or lo_stat to the 'stations' variable.
+    ; But 'stations' is used outside this loop, and we don't want to clobber it
+    ; for the next iteration.  I changed this to a local variable loop_stations,
+    ; which seems to work.
+    ; JWL 12-30-2023
+    
+    if w eq 0 then begin
+      loop_stations = hi_stat
+      skip = skip_hi
+    endif else begin
+      loop_stations = lo_stat
+      skip = skip_lo
+    endelse

+    if skip eq 1 then continue  ; skip processing if no stations available
+    
     ;create tplot variables of components
-    num_elements = n_elements(stations)
+    num_elements = n_elements(loop_stations)
     h_axis_range = dblarr(2)
     d_axis_range = dblarr(2)
     z_axis_range = dblarr(2)
@@ -227,28 +248,28 @@
     max_dev = [min(max_dev), max(max_dev)]

     for i = 0, num_elements-1 do begin
-      get_data, 'thg_mag_'+stations[i], data = dd
+      get_data, 'thg_mag_'+loop_stations[i], data = dd
       index_time = where(dd.x ge start_time and dd.x le end_time)
       themedian = strcompress(string(median(dd.y[index_time, 0], /even), format = '(f10.1)'), /remove_all)
       hdata = dd.y[index_time, 0]-median(dd.y[index_time, 0], /even)
       xclip, max_dev[0], max_dev[1], hdata, /clip_adjacent
       hdata = hdata+stack_shift*i
-      store_data, 'thg_mag_'+stations[i]+'_h_rel', data = {x:dd.x[index_time], y:hdata}, $
-        limits = {labels:[strupcase(stations[i])+'='+string(themedian)]}
+      store_data, 'thg_mag_'+loop_stations[i]+'_h_rel', data = {x:dd.x[index_time], y:hdata}, $
+        limits = {labels:[strupcase(loop_stations[i])+'='+string(themedian)]}

       themedian = strcompress(string(median(dd.y[index_time, 1], /even), format = '(f10.1)'), /remove_all)
       ddata = dd.y[index_time, 1]-median(dd.y[index_time, 1], /even)
       xclip, max_dev[0], max_dev[1], ddata, /clip_adjacent
       ddata = ddata+stack_shift*i
-      store_data, 'thg_mag_'+stations[i]+'_d_rel', data = {x:dd.x[index_time], y:ddata}, $
-        limits = {labels:[strupcase(stations[i])+'='+string(themedian)]}
+      store_data, 'thg_mag_'+loop_stations[i]+'_d_rel', data = {x:dd.x[index_time], y:ddata}, $
+        limits = {labels:[strupcase(loop_stations[i])+'='+string(themedian)]}

       themedian = strcompress(string(median(dd.y[index_time, 2], /even), format = '(f10.1)'), /remove_all)
       zdata = dd.y[index_time, 2]-median(dd.y[index_time, 2], /even)
       xclip, max_dev[0], max_dev[1], zdata, /clip_adjacent
       zdata = zdata+stack_shift*i
-      store_data, 'thg_mag_'+stations[i]+'_z_rel', data = {x:dd.x[index_time], y:zdata}, $
-        limits = {labels:[strupcase(stations[i])+'='+string(themedian)]}
+      store_data, 'thg_mag_'+loop_stations[i]+'_z_rel', data = {x:dd.x[index_time], y:zdata}, $
+        limits = {labels:[strupcase(loop_stations[i])+'='+string(themedian)]}

       if max(hdata) gt h_axis_range[1] then h_axis_range[1] = max(hdata)
       if max(ddata) gt d_axis_range[1] then d_axis_range[1] = max(ddata)
@@ -307,10 +328,10 @@
     tplotvars_d = ['filler']
     tplotvars_z = ['filler']

-    for i = 0, n_elements(stations)-1 do begin
-      tplotvars_h = [tplotvars_h, tnames('thg_mag_'+stations[i]+'_h_rel')]
-      tplotvars_d = [tplotvars_d, tnames('thg_mag_'+stations[i]+'_d_rel')]
-      tplotvars_z = [tplotvars_z, tnames('thg_mag_'+stations[i]+'_z_rel')]
+    for i = 0, n_elements(loop_stations)-1 do begin
+      tplotvars_h = [tplotvars_h, tnames('thg_mag_'+loop_stations[i]+'_h_rel')]
+      tplotvars_d = [tplotvars_d, tnames('thg_mag_'+loop_stations[i]+'_d_rel')]
+      tplotvars_z = [tplotvars_z, tnames('thg_mag_'+loop_stations[i]+'_z_rel')]
     endfor

     store_data, 'BH', data = [tplotvars_h[1:*], 'BUFFER_TOP_H', 'BUFFER_BOT_H']