spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
143 stars 58 forks source link

Add time_clip option to cda_download() and cdaweb GUI #863

Closed jameswilburlewis closed 3 weeks ago

jameswilburlewis commented 1 month ago

Some missions, for example New Horizons, store very long time intervals in a single data CDF. When downloading via cda_download(), we should have a time_clip option that trims the returned data down to the specific times requested by the user.

Example, again from Nick Gross on Helionauts:

import pyspedas
from pytplot import tplot

cdaweb_obj = pyspedas.CDAWeb()
mission_list = ['New Horizons']
#instrument_list = ['Plasma and Solar Wind']
instrument_list = ['Particles (space)']
dataset_list = cdaweb_obj.get_datasets(mission_list, instrument_list)
print(dataset_list)
dataset = 'NEW_HORIZONS_SWAP_VALIDSUM (2008-10-10 to 2023-07-31)'
start_time = '2009-10-10 00:00:00'
end_time = '2009-11-10 00:00:00'

# Get the URLs for the available data in this time range
urllist = cdaweb_obj.get_filenames([dataset],start_time, end_time)

cdaweb_obj.cda_download(urllist,"cdaweb/",prefix='nh_')

tplot('nh_n')

This actually plots data from 2008 through 2023! It's all in a single CDF.