mangonetwork / mangopy

This repository contains code for processing all-sky images generated by the Mid-latitude All-sky-imager Network for Geophysical Observations (MANGO), a project funded by the National Science Foundation.
GNU General Public License v3.0
6 stars 2 forks source link

Option to NOT attempt to download data #7

Closed ljlamarche closed 3 years ago

ljlamarche commented 5 years ago

Create a flag so mangopy will NOT attempt to download data from the ftp site if it is not found locally. This would be a good way to handle a user making many plots of a night when certain cameras are not on. If the user is sure they have all the available data, it is not helpful for mangopy to keep checking the server for files that do not exist.

pmreyes2 commented 5 years ago

That would be very useful. I assume this is the function in question: get_data right?

ljlamarche commented 5 years ago

I believe so. What we'd probably want to do is add an additional option to the except statement.

try:
    img_array, lat, lon, truetime = self.read_datafile(filename,targtime)
# if that fails, try to download, then read the data file
except (OSError, IOError):
############### POTENTIAL ADDITION ######################
    if download_data == False:
        ....
#######################################################
    print('Attempting to download {} from FTP server.'.format(os.path.basename(filename)))
    self.fetch_datafile(site, targtime.date())
img_array, lat, lon, truetime = self.read_datafile(filename,targtime)

However, the current usage of mangopy doen't really involve users using get_data directly (you just initialize Mango or Mosaic and it handles the rest from there), so we may have to put specification of whether or not to download data as an initialization option. We probably also want to think about what exactly the desired behavior is. If you specify to only use local data and mangopy can't find a particular file, should it raise an error or just do nothing?

pmreyes2 commented 5 years ago

Well, one can have a list of the available data locally, and ideally also a list of the available data (that can be updated with a method update_remote_list()) in the server. Then there could be methods : data_exists_locally() and/or data_exists_remotely() before attempting to read or fetch data. Then, I agree that when initializing Mango or Mosaic we can pass a parameter download_data=False to avoid fetching data remotely. self.download_data can be used inside the try/except inside get_data . The self.download_data parameter could also be updated with a method.

ljlamarche commented 3 years ago

Finished.