No problem at all, and thanks for the info! I have just reformatted the code so it becomes more readable.
I think I have found where the problem is. The code works fine, and does what is required, however, it is asking (within your timeframe) for data that does not exist. I’ll explain myself:
This station started streaming data to our servers @ 12:39:25UTC on 2023-09-28 (yesterday).
Your data request timeframe goes from today’s midnight (00:00:00UTC on 2023-09-29) to yesterday’s midnight (00:00:00UTC on 2023-09-28).
As you can see, there is a period between 00:00:00UTC yesterday and 12:39:25UTC yesterday where there is no data, and thus no instrument response available.
You can verify this if you modify this line
starttime = UTCDateTime(endtime - timedelta(days=1))
to
starttime = UTCDateTime(endtime - timedelta(hours=11))
Now the code works, and it correctly downloads and uses the response data to process the traces you have downloaded.
This is because the modified line translates to a datetime of 13:00:00UTC on 2023-09-28, where there is plenty of data available.
In conclusion, you can use this modified function to download data today, and then you can go back to your days=1
starttime
tomorrow, where more than 24h of data will be present on server:
def fetch_daily_seismic_data(client, station, folder):
rs = Client(client)
endtime = UTCDateTime(date.today() ) #REUNION =UTC +4 ==> trace de 4h à 4h du mat
starttime = UTCDateTime(endtime - timedelta(hours=11))
st=Stream()
for channel in ['EHZ','EHN','EHE'] : #EHZ/EHN/EHE Short Period 100 sps
tr = rs.get_waveforms('AM',station, '00', channel, starttime, endtime)
net = tr[0].stats.network
loc = tr[0].stats.location
filename = generate_seismic_filename(net, station, loc, channel,
starttime)
tr.write(os.path.join(folder, filename), format='MSEED')
inv = rs.get_stations(network='AM', station=station,channel=channel,
starttime=starttime, endtime=endtime,
level="response")
tr.remove_response(inventory=inv)
tr.merge(method=0, interpolation_samples=0, fill_value=None)
st.append(tr[0])
return st, inventory
For anything else, I remain available.