Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -111,12 +111,14 @@ 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 |
-
|
|
|
115 |
instrument = a.Instrument.hmi if "hmi" in channel else a.Instrument.aia
|
116 |
-
query = Fido.search(time_attr, instrument, physobs, sample
|
117 |
|
118 |
-
if not query: raise ValueError(f"No data found for {channel} near {t}")
|
119 |
-
|
|
|
120 |
data_maps[t][channel] = sunpy.map.Map(files[0])
|
121 |
|
122 |
yield "✅ All files downloaded. Starting preprocessing..."
|
@@ -138,7 +140,6 @@ def fetch_and_process_sdo_data(target_dt, forecast_horizon_minutes):
|
|
138 |
if exp_time is None or exp_time <= 0: exp_time = 1.0
|
139 |
norm_data = reprojected_data / exp_time
|
140 |
|
141 |
-
# *** FIX: Corrected the syntax error on this line ***
|
142 |
scaled_data = scaler.transform(norm_data.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)
|
|
|
111 |
if data_maps[t].get("hmi_bx"): data_maps[t][channel] = data_maps[t]["hmi_bx"]
|
112 |
continue
|
113 |
|
114 |
+
# *** FIX: Removed the non-existent 'a.Time.nearest' attribute. ***
|
115 |
+
time_attr = a.Time(t - datetime.timedelta(minutes=5), t + datetime.timedelta(minutes=5))
|
116 |
instrument = a.Instrument.hmi if "hmi" in channel else a.Instrument.aia
|
117 |
+
query = Fido.search(time_attr, instrument, physobs, sample)
|
118 |
|
119 |
+
if not query: raise ValueError(f"No data found for {channel} near {t}. Try a slightly different time.")
|
120 |
+
# We fetch the first result, which is the closest match within the window.
|
121 |
+
files = Fido.fetch(query[0,0], path="./data/sdo_cache")
|
122 |
data_maps[t][channel] = sunpy.map.Map(files[0])
|
123 |
|
124 |
yield "✅ All files downloaded. Starting preprocessing..."
|
|
|
140 |
if exp_time is None or exp_time <= 0: exp_time = 1.0
|
141 |
norm_data = reprojected_data / exp_time
|
142 |
|
|
|
143 |
scaled_data = scaler.transform(norm_data.reshape(-1, 1), c_idx=i).reshape(norm_data.shape)
|
144 |
channel_tensors.append(torch.from_numpy(scaled_data.astype(np.float32)))
|
145 |
processed_tensors[t] = torch.stack(channel_tensors)
|