Skip to content
Snippets Groups Projects
Unverified Commit 112e931c authored by David Hoese's avatar David Hoese
Browse files

Add thumbnail logic to files api

parent 7d264747
Branches
No related tags found
No related merge requests found
......@@ -72,6 +72,8 @@ def get_data(dates, streams, frame=True):
file_info['url'] = os.path.join(app.config['ARCHIVE_URL'], path)
file_info['size'] = os.stat(pathname).st_size
file_info['relpath'] = path
if file_info['thumbnail'] is not None:
file_info['thumbnail'] = dt.strftime(file_info['thumbnail'])
data.append(file_info)
if frame:
......
......@@ -32,40 +32,48 @@ ARCHIVE_INFO = {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.%Y-%m-%d.nc',
'display_name': 'Daily NetCDF file (aoss_tower.YYYY-MM-DD.nc)',
'preview_product': 'meteorogram-daily',
},
'meteorogram-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.meteorogram.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.meteorogram.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Meteorogram (aoss_tower.meteorogram.YYYY-MM-DD.png)',
},
'td-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.td.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.td.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Air and Dewpoint Temperature (aoss_tower.td.YYYY-MM-DD.png)',
},
'pressure-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.pressure.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.pressure.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Pressure (aoss_tower.pressure.YYYY-MM-DD.png)',
},
'wind-speed-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.wind_speed.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.wind_speed.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Wind Speed (aoss_tower.wind_speed.YYYY-MM-DD.png)',
},
'wind-dir-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.wind_dir.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.wind_dir.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Wind Direction (aoss_tower.wind_dir.YYYY-MM-DD.png)',
},
'accum-precip-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.accum_precip.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.accum_precip.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Accumulated Precipitation (aoss_tower.accum_precip.YYYY-MM-DD.png)',
},
'solar-flux-daily': {
'frequency': ProductFrequency.DAILY_FILE,
'pattern': 'aoss_tower.solar_flux.%Y-%m-%d.png',
'thumbnail_pattern': 'aoss_tower.solar_flux.%Y-%m-%d_thumbnail.png',
'display_name': 'Daily Solar Flux (aoss_tower.solar_flux.YYYY-MM-DD.png)',
},
},
......@@ -173,6 +181,10 @@ for site, site_info in ARCHIVE_INFO.items():
'version': version,
'file_pattern': pattern_info['pattern']
}
if 'thumbnail_pattern' in pattern_info:
stream_info['thumbnail'] = path.replace(pattern_info['pattern'], pattern_info['thumbnail_pattern'])
else:
stream_info['thumbnail'] = None
ARCHIVE_STREAMS[stream_id] = stream_info
INSTRUMENT_STREAMS[inst_name].append(stream_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment