broadfield-dev commited on
Commit
cad05b5
·
verified ·
1 Parent(s): 9f9c5a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -111,8 +111,10 @@ def fetch_and_process_sdo_data(target_dt, forecast_horizon_minutes):
111
  if data_maps[t].get("hmi_bx"): data_maps[t][channel] = data_maps[t]["hmi_bx"]
112
  continue
113
 
 
 
114
  instrument = a.Instrument.hmi if "hmi" in channel else a.Instrument.aia
115
- query = Fido.search(a.Time(t), instrument, physobs, sample, a.Time.nearest==True)
116
 
117
  if not query: raise ValueError(f"No data found for {channel} near {t}")
118
  files = Fido.fetch(query, path="./data/sdo_cache")
@@ -137,7 +139,7 @@ def fetch_and_process_sdo_data(target_dt, forecast_horizon_minutes):
137
  if exp_time is None or exp_time <= 0: exp_time = 1.0
138
  norm_data = reprojected_data / exp_time
139
 
140
- scaled_data = scaler.transform(norm_data, c_idx=i)
141
  channel_tensors.append(torch.from_numpy(scaled_data.astype(np.float32)))
142
  processed_tensors[t] = torch.stack(channel_tensors)
143
 
 
111
  if data_maps[t].get("hmi_bx"): data_maps[t][channel] = data_maps[t]["hmi_bx"]
112
  continue
113
 
114
+ # *** FIX: Provide a valid time range for the Fido search query. ***
115
+ time_attr = a.Time(t - datetime.timedelta(minutes=2), t + datetime.timedelta(minutes=2))
116
  instrument = a.Instrument.hmi if "hmi" in channel else a.Instrument.aia
117
+ query = Fido.search(time_attr, instrument, physobs, sample, a.Time.nearest==True)
118
 
119
  if not query: raise ValueError(f"No data found for {channel} near {t}")
120
  files = Fido.fetch(query, path="./data/sdo_cache")
 
139
  if exp_time is None or exp_time <= 0: exp_time = 1.0
140
  norm_data = reprojected_data / exp_time
141
 
142
+ scaled_data = scaler.transform(.reshape(-1, 1), c_idx=i).reshape(norm_data.shape)
143
  channel_tensors.append(torch.from_numpy(scaled_data.astype(np.float32)))
144
  processed_tensors[t] = torch.stack(channel_tensors)
145