Mercurial > repos > greg > validate_temperature_data
comparison validate_temperature_data.py @ 14:59b9339c2ed6 draft
Uploaded
author | greg |
---|---|
date | Tue, 27 Nov 2018 10:49:09 -0500 |
parents | e33fdb18762f |
children | 13de3d5839ac |
comparison
equal
deleted
inserted
replaced
13:e33fdb18762f | 14:59b9339c2ed6 |
---|---|
126 accumulated_msgs = validate_decimal(i, tmin, accumulated_msgs, "tmin") | 126 accumulated_msgs = validate_decimal(i, tmin, accumulated_msgs, "tmin") |
127 tmax = items[9].strip() | 127 tmax = items[9].strip() |
128 accumulated_msgs = validate_decimal(i, tmax, accumulated_msgs, "tmax") | 128 accumulated_msgs = validate_decimal(i, tmax, accumulated_msgs, "tmax") |
129 else: | 129 else: |
130 if i == 0: | 130 if i == 0: |
131 try: | |
132 last_doy = int(doy) | |
133 except Exception: | |
134 accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains an invalid DOY (%s must be an integer)." % (i, doy)) | |
135 stop_error(accumulated_msgs) | |
131 if line != ACTUALS_HEADER: | 136 if line != ACTUALS_HEADER: |
132 accumulated_msgs = add_error_msg(accumulated_msgs, "The header is invalid, must be %s" % ACTUALS_HEADER) | 137 accumulated_msgs = add_error_msg(accumulated_msgs, "The header is invalid, must be %s" % ACTUALS_HEADER) |
133 continue | 138 continue |
134 if i > 367: | 139 if i > 367: |
135 accumulated_msgs = add_error_msg(accumulated_msgs, "The input file contains more than 367 lines (must be 1 header line and no more than 366 data lines).") | 140 accumulated_msgs = add_error_msg(accumulated_msgs, "The input file contains more than 367 lines (must be 1 header line and no more than 366 data lines).") |
144 date_string = items[2].strip() | 149 date_string = items[2].strip() |
145 accumulated_msgs = validate_date_string(i, date_string, accumulated_msgs) | 150 accumulated_msgs = validate_date_string(i, date_string, accumulated_msgs) |
146 doy = items[3].strip() | 151 doy = items[3].strip() |
147 accumulated_msgs = validate_integer(i, doy, accumulated_msgs, "doy") | 152 accumulated_msgs = validate_integer(i, doy, accumulated_msgs, "doy") |
148 # Make sure the DOY values are consecutive. | 153 # Make sure the DOY values are consecutive. |
149 if i==0: | 154 try: |
150 last_doy = int(doy) | 155 if int(doy) != (last_doy + 1): |
151 else: | 156 accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains a DOY (%s) that is not conexcutive." % (i, doy)) |
152 try: | 157 stop_error(accumulated_msgs) |
153 if int(doy) != (last_doy + 1): | 158 except Exception: |
154 accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains a DOY (%s) that is not conexcutive." % (i, doy)) | 159 # The error for an invalid integer was captured above. |
155 stop_error(accumulated_msgs) | 160 pass |
156 except Exception: | 161 last_doy += 1 |
157 # The error for an invalid integer was captured above. | |
158 pass | |
159 last_doy += 1 | |
160 tmin = items[4].strip() | 162 tmin = items[4].strip() |
161 accumulated_msgs = validate_decimal(i, tmin, accumulated_msgs, "tmin") | 163 accumulated_msgs = validate_decimal(i, tmin, accumulated_msgs, "tmin") |
162 tmax = items[5].strip() | 164 tmax = items[5].strip() |
163 accumulated_msgs = validate_decimal(i, tmax, accumulated_msgs, "tmax") | 165 accumulated_msgs = validate_decimal(i, tmax, accumulated_msgs, "tmax") |
164 if args.data_type == "normals" and num_normals_rows != 367: | 166 if args.data_type == "normals" and num_normals_rows != 367: |