Skip to content

Commit

Permalink
Merge pull request #154 from opencdms/monthly-form-update
Browse files Browse the repository at this point in the history
Monthly Capture Updates
  • Loading branch information
fabiosato authored Oct 11, 2024
2 parents 8084028 + 7d794b6 commit 6dfb068
Show file tree
Hide file tree
Showing 6 changed files with 650 additions and 39 deletions.
90 changes: 90 additions & 0 deletions api/fixtures/wx_variable.json
Original file line number Diff line number Diff line change
Expand Up @@ -4198,5 +4198,95 @@
"default_representation": "column",
"synoptic_code_form": "RRR"
}
},
{
"model": "wx.variable",
"pk": 4052,
"fields": {
"created_at": "2024-10-08T22:10:06.033Z",
"updated_at": "2024-10-08T22:10:06.033Z",
"variable_type": "Numeric",
"symbol": "DYGAIL",
"name": "Day with Gail",
"sampling_operation": null,
"measurement_variable": null,
"unit": null,
"precision": null,
"scale": null,
"code_table": null,
"color": null,
"range_min": null,
"range_max": null,
"range_min_hourly": null,
"range_max_hourly": null,
"step": null,
"step_hourly": null,
"persistence": null,
"persistence_hourly": null,
"persistence_window": null,
"persistence_window_hourly": null,
"default_representation": "line",
"synoptic_code_form": null
}
},
{
"model": "wx.variable",
"pk": 4053,
"fields": {
"created_at": "2024-10-08T22:11:32.101Z",
"updated_at": "2024-10-08T22:11:32.101Z",
"variable_type": "Numeric",
"symbol": "EVAPINI",
"name": "Evaporation Initial (mm.)",
"sampling_operation": 6,
"measurement_variable": 4,
"unit": 2,
"precision": 5,
"scale": 2,
"code_table": null,
"color": "#FF0000",
"range_min": null,
"range_max": null,
"range_min_hourly": null,
"range_max_hourly": null,
"step": null,
"step_hourly": null,
"persistence": null,
"persistence_hourly": null,
"persistence_window": null,
"persistence_window_hourly": null,
"default_representation": "bar",
"synoptic_code_form": null
}
},
{
"model": "wx.variable",
"pk": 4054,
"fields": {
"created_at": "2024-10-08T22:11:32.101Z",
"updated_at": "2024-10-08T22:11:32.101Z",
"variable_type": "Numeric",
"symbol": "EVAPRES",
"name": "Evaporation Reset (mm.)",
"sampling_operation": 6,
"measurement_variable": 4,
"unit": 2,
"precision": 5,
"scale": 2,
"code_table": null,
"color": "#FF0000",
"range_min": null,
"range_max": null,
"range_min_hourly": null,
"range_max_hourly": null,
"step": null,
"step_hourly": null,
"persistence": null,
"persistence_hourly": null,
"persistence_window": null,
"persistence_window_hourly": null,
"default_representation": "bar",
"synoptic_code_form": null
}
}
]
2 changes: 2 additions & 0 deletions api/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@
<div class="collapsible-subitem mb-2">
<ul class="collection">
<a id="daily-form" href="{% url 'daily-form' %}" class="hide-menu collection-item left-space" onclick="mainOverlayLoader()">Daily Capture Form<i class="material-icons secondary-content">keyboard</i></a>
<a id="monthly-form" href="{% url 'monthly-form' %}" class="hide-menu collection-item left-space" onclick="mainOverlayLoader()">New Monthly Capture<i class="material-icons secondary-content">keyboard</i></a>
<a id="synop-capture" href="{% url 'synop-capture' %}" class="hide-menu collection-item left-space" onclick="mainOverlayLoader()">SYNOP Capture Form<i class="material-icons secondary-content">keyboard</i></a>
<a id="synop-capture-update" href="{% url 'synop-capture-update' %}" class="hide-menu collection-item left-space" onclick="mainOverlayLoader()">New SYNOP Capture<i class="material-icons secondary-content">keyboard</i></a>
<a id="data-export" href="{% url 'data-export' %}" class="hide-menu collection-item left-space" onclick="mainOverlayLoader()">Export<i class="material-icons secondary-content">cloud_download</i></a>
Expand Down Expand Up @@ -812,6 +813,7 @@ <h1>SURFACE</h1>
'station-oscar-export',
'stations-monitoring',
'daily-form',
'monthly-form',
'synop-capture',
'synop-capture-update',
'data-export',
Expand Down
95 changes: 57 additions & 38 deletions api/wx/decoders/manual_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,55 @@

column_names = [
'day',
'rainfall',
'temp_max',
'temp_min',
'wind_cup_counter',
'wind_24h_thrown_back',
'sunshine',
'evaporation_initial',
'evaporation_reset',
'evaporation_24h_thrown_back',
'dry_bulb',
'wet_bulb',
'soil_temp_1_foot',
'soil_temp_4_foot',
'weather_ts',
'weather_fog',
'total_rad'
'PRECIP',
'TEMPMAX',
'TEMPMIN',
'TEMPAVG',
'WNDMIL',
'WINDRUN',
'SUNSHNHR',
'EVAPINI',
'EVAPRES',
'EVAPPAN',
'TEMP',
'TEMPWB',
'TSOIL1',
'TSOIL4',
'DYTHND',
'DYFOG',
'DYHAIL',
'DYGAIL',
'TOTRAD',
'RH@TMAX',
'RHMAX',
'RHMIN',
]

# verificar
variable_dict = {
'rainfall': 0,
'temp_min': 14,
'temp_max': 16,
'wind_cup_counter': 102,
'wind_24h_thrown_back': 103,
'sunshine': 77,
# 'evaporation_initial',
# 'evaporation_reset',
'evaporation_24h_thrown_back': 40,
'dry_bulb': 10,
'wet_bulb': 18,
'soil_temp_1_foot': 21,
'soil_temp_4_foot': 23,
'weather_ts': 104,
'weather_fog': 106,
'total_rad': 70
'PRECIP': 0,
'TEMPMAX': 16,
'TEMPMIN': 14,
'TEMPAVG': 12,
'SUNSHNHR': 77,
'WNDMIL': 102,
'WINDRUN': 103,
'EVAPINI': 4053,
'EVAPRES': 4054,
'EVAPPAN': 40,
'TEMP': 10,
'TEMPWB': 18,
'TSOIL1': 21,
'TSOIL4': 23,
'DYTHND': 104,
'DYHAIL': 105,
'DYFOG': 106,
'DYGAIL': 4052,
'TOTRAD': 70,
'RH@TMAX': 34,
'RHMAX': 33,
'RHMIN': 32,
}


def parse_date(month_datetime, day, utc_offset):
datetime_offset = pytz.FixedOffset(utc_offset)
date = month_datetime.replace(day=day)
Expand Down Expand Up @@ -123,26 +133,35 @@ def read_file(filename, highfrequency_data=False, station_object=None, utc_offse

# iterate over the sheets
for sheet_name in source.sheet_names:
sheet_raw_data = source.parse(sheet_name, skipfooter=2, na_filter=False, names=column_names, usecols='A:Q')
sheet_raw_data = source.parse(
sheet_name,
skipfooter=2,
na_filter=False,
names=column_names,
usecols='A:W'
)

if not sheet_raw_data.empty:
header = sheet_raw_data[0:1]
sheet_data = sheet_raw_data[7:]

# get the sheet station info
station_name = sheet_name.strip()
station = find_station_by_name(station_name)

station_id = station.id

# get the sheet data info
if date_info is None:
sheet_month = header['sunshine'][0].replace('MONTH: ', '').strip()
sheet_year = header['evaporation_24h_thrown_back'][0].replace('YEAR: ', '').strip()
sheet_month = header['WINDRUN'][0].replace('MONTH: ', '').strip()
sheet_year = header['EVAPRES'][0].replace('YEAR: ', '').strip()
date_info = {'month': sheet_month, 'year': sheet_year}
else:
sheet_month = date_info['month']
sheet_year = date_info['year']

print(sheet_month)
print(sheet_year)

# filter the sheet day
month_datetime = datetime.datetime.strptime(f'{sheet_month} {sheet_year}', '%B %Y')
first_month_day, last_month_day = calendar.monthrange(month_datetime.year, month_datetime.month)
Expand Down
Loading

0 comments on commit 6dfb068

Please sign in to comment.