From b1559bc1ba1fe30b3c112a69625c8d371aa9a3d6 Mon Sep 17 00:00:00 2001 From: david-i-berry Date: Wed, 20 Sep 2023 15:37:35 +0200 Subject: [PATCH] Updated csv limits. (#16) * Updated csv limits. * Fix nulls failing validation. --- webapp/public/csv2bufr/csvw_schema.json | 133 +++++++++++------------- webapp/src/components/CsvToBUFRForm.vue | 4 +- 2 files changed, 64 insertions(+), 73 deletions(-) diff --git a/webapp/public/csv2bufr/csvw_schema.json b/webapp/public/csv2bufr/csvw_schema.json index 951d7f5..334b701 100644 --- a/webapp/public/csv2bufr/csvw_schema.json +++ b/webapp/public/csv2bufr/csvw_schema.json @@ -6,47 +6,47 @@ { "titles": "wsi_series", "dc:description": "WIGOS identifier series", - "datatype": {"base": "integer"}, + "datatype": {"base": "integer", "minimum": 0, "maximum": 0}, "null": "null" }, { "titles": "wsi_issuer", "dc:description": "WIGOS issuer of identifier", - "datatype": {"base": "integer"}, + "datatype": {"base": "integer", "minimum": 0, "maximum": 65534}, "null": "null" }, { "titles": "wsi_issue_number", "dc:description": "WIGOS issue number", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 65534} }, { "titles": "wsi_local", "dc:description": "WIGOS local identifier", - "datatype": {"base": "string"} + "datatype": {"base": "string", "maxLength": 16} }, { "titles": "wmo_block_number", "dc:description": "WMO block number", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 99} }, { "titles": "wmo_station_number", "dc:description": "WMO station number", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 999} }, { "titles": "station_type", "dc:description": "Type of observing station, encoding using code table 0 02 001 (set to 0, automatic)", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 3} }, { "titles": "year", "dc:description": "Year (UTC), the time of observation (based on the actual time the barometer is read)", "datatype": { "base": "integer", - "minimum": "1900", - "maximum": "2023" + "minimum": 1600, + "maximum": 2200 } }, { @@ -54,8 +54,8 @@ "dc:description": "Month (UTC), the time of observation (based on the actual time the barometer is read)", "datatype": { "base": "integer", - "minimum": "1", - "maximum": "12" + "minimum": 1, + "maximum": 12 } }, { @@ -63,8 +63,8 @@ "dc:description": "Day (UTC), the time of observation (based on the actual time the barometer is read)", "datatype": { "base": "integer", - "minimum": "1", - "maximum": "31" + "minimum": 1, + "maximum": 31 } }, { @@ -72,8 +72,8 @@ "dc:description": "Hour (UTC), the time of observation (based on the actual time the barometer is read)", "datatype": { "base": "integer", - "minimum": "0", - "maximum": "23" + "minimum": 0, + "maximum": 23 } }, { @@ -81,8 +81,8 @@ "dc:description": "Minute (UTC), the time of observation (based on the actual time the barometer is read)", "datatype": { "base": "integer", - "minimum": "0", - "maximum": "59" + "minimum": 0, + "maximum": 59 } }, { @@ -90,8 +90,8 @@ "dc:description": "Latitude of the station (to 5 decimal places)", "datatype": { "base": "decimal", - "minimum": "-90", - "maximum": "90" + "minimum": -90, + "maximum": 90 } }, { @@ -99,62 +99,52 @@ "dc:description": "Longitude of the station (to 5 decimal places)", "datatype": { "base": "decimal", - "minimum": "-180", - "maximum": "180" + "minimum": -180, + "maximum": 180 } }, { "titles": "station_height_above_msl", "dc:description": "Height of the station ground above mean sea level (to 1 decimal place)", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": -500, "maximum": 9000} }, { "titles": "barometer_height_above_msl", "dc:description": "Height of the barometer above mean sea level (to 1 decimal place), typically height of station ground plus the height of the sensor above local ground", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": -500, "maximum": 9000} }, { "titles": "station_pressure", "dc:description": "Pressure observed at the station level to the nearest 10 pascals", - "datatype": { - "base": "integer", - "minimum": "50000", - "maximum": "150000" - } + "datatype": {"base": "integer", "minimum": 50000, "maximum": 150000} }, { "titles": "msl_pressure", "dc:description": "Pressure reduced to mean sea level to the nearest 10 pascals", - "datatype": { - "base": "integer", - "minimum": "50000", - "maximum": "150000" - } + "datatype": {"base": "integer", "minimum": 50000, "maximum": 150000} }, { "titles": "geopotential_height", "dc:description": "Geoptential height expressed in geopotential meters (gpm) to 0 decimal places", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": -4000, "maximum": 1306710} }, { "titles": "thermometer_height", "dc:description": "Height of thermometer or temperature sensor above the local ground to 2 decimal places", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 655.35} }, { "titles": "air_temperature", "dc:description": "Instantaneous air temperature to 2 decimal places", "datatype": { - "base": "decimal", - "minimum": "0" + "base": "decimal", "minimum": 193.15, "maximum": 333.15 } }, { "titles": "dewpoint_temperature", "dc:description": "Instantaneous dewpoint temperature to 2 decimal places", "datatype": { - "base": "decimal", - "minimum": "0" + "base": "decimal", "minimum": 193.15, "maximum": 308.15 } }, { @@ -162,118 +152,115 @@ "dc:description": "Instantaneous relative humidity to zero decimal places", "datatype": { "base": "integer", - "minimum": "0", - "maximum": "150" + "minimum": 0, + "maximum": 150 } }, { "titles": "method_of_ground_state_measurement", "dc:description": "Method of observing the state of the ground, encoded using code table 0 02 176", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 15} }, { "titles": "ground_state", "dc:description": "State of the ground encoded using code table 0 20 062", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 31} }, { "titles": "method_of_snow_depth_measurement", "dc:description": "Method of observing the snow depth encoded using code table 0 02 177", - "datatype": {"base": "integer"} + "datatype": {"base": "integer", "minimum": 0, "maximum": 15} }, { "titles": "snow_depth", "dc:description": "Snow depth at time of observation to 2 decimal places", "datatype": { - "base": "decimal", - "minimum": "0" + "base": "decimal", "minimum": -0.02, "maximum": 655.33 } }, { "titles": "precipitation_intensity", "dc:description": "Intensity of precipitation at time of observation to 5 decimal places", "datatype": { - "base": "decimal", - "minimum": "0" + "base": "decimal", "minimum": -0.00001, "maximum": 0.65534 } }, { "titles": "anemometer_height", "dc:description": "Height of the anemometer above local ground to 2 decimal place", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 655.35} }, { "titles": "time_period_of_wind", - "dc:description": "Time period over which the wind speed and direction have been averaged. 10 minutes in normal cases or the number of minutes since a significant change occuring in the preceeding 10 minutes.", - "datatype": {"base": "negativeInteger"} + "dc:description": "Time period over which the wind speed and direction have been averaged. 10 minutes in normal cases or the number of minutes since a significant change occurring in the preceding 10 minutes.", + "datatype": {"base": "integer", "minimum": -10, "maximum": 0} }, { "titles": "wind_direction", - "dc:description": "Wind direction (at anemometer height) averaged from the caterisan components over the indicated time period, 0 decimal places", + "dc:description": "Wind direction (at anemometer height) averaged from the cartesian components over the indicated time period, 0 decimal places", "datatype": { - "base": "integer", - "minimum": "0", - "maximum": "360" + "base": "integer", "minimum": 0, "maximum": 360 } }, { "titles": "wind_speed", "dc:description": "Wind speed (at anemometer height) averaged from the cartesian components over the indicated time period, 1 decimal place", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 409.5} }, { "titles": "maximum_wind_gust_direction_10_minutes", "dc:description": "Highest 3 second average over the preceding 10 minutes, 0 decimal places", "datatype": { "base": "integer", - "minimum": "0", - "maximum": "360" + "minimum": 0, + "maximum": 360 } }, { "titles": "maximum_wind_gust_speed_10_minutes", "dc:description": "Highest 3 second average over the preceding 10 minutes, 1 decimal place", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 409.5} }, { "titles": "maximum_wind_gust_direction_1_hour", "dc:description": "Highest 3 second average over the preceding hour, 0 decimal places", "datatype": { "base": "integer", - "minimum": "0", - "maximum": "360" + "minimum": 0, + "maximum": 360 } }, { "titles": "maximum_wind_gust_speed_1_hour", "dc:description": "Highest 3 second average over the preceding hour, 1 decimal place", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 409.5} }, { "titles": "maximum_wind_gust_direction_3_hours", "dc:description": "Highest 3 second average over the preceding 3 hours, 0 decimal places", "datatype": { "base": "integer", - "minimum": "0", - "maximum": "360" + "minimum": 0, + "maximum": 360 } }, { "titles": "maximum_wind_gust_speed_3_hours", "dc:description": "Highest 3 second average over the preceding 3 hours, 1 decimal place", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 409.5} }, { "titles": "rain_sensor_height", "dc:description": "Height of the rain gauge above local ground to 2 decimal place", - "datatype": {"base": "decimal"} + "datatype": {"base": "decimal", "minimum": 0, "maximum": 655.35} }, { "titles": "total_precipitation_1_hour", "dc:description": "Total precipitation over the past hour, 1 decimal place", "datatype": { "base": "decimal", - "minimum": "0" + "minimum": -0.1, + "maximum": 1638.2 } }, { @@ -281,7 +268,8 @@ "dc:description": "Total precipitation over the past 3 hours, 1 decimal place", "datatype": { "base": "decimal", - "minimum": "0" + "minimum": -0.1, + "maximum": 1638.2 } }, { @@ -289,7 +277,8 @@ "dc:description": "Total precipitation over the past 6 hours, 1 decimal place", "datatype": { "base": "decimal", - "minimum": "0" + "minimum": -0.1, + "maximum": 1638.2 } }, { @@ -297,7 +286,8 @@ "dc:description": "Total precipitation over the past 12 hours, 1 decimal place", "datatype": { "base": "decimal", - "minimum": "0" + "minimum": -0.1, + "maximum": 1638.2 } }, { @@ -305,7 +295,8 @@ "dc:description": "Total precipitation over the past 24 hours, 1 decimal place", "datatype": { "base": "decimal", - "minimum": "0" + "minimum": -0.1, + "maximum": 1638.2 } } ] diff --git a/webapp/src/components/CsvToBUFRForm.vue b/webapp/src/components/CsvToBUFRForm.vue index c98446a..b5ada6e 100644 --- a/webapp/src/components/CsvToBUFRForm.vue +++ b/webapp/src/components/CsvToBUFRForm.vue @@ -360,7 +360,7 @@ if( header.dataType.minimum ){ valid_min = header.dataType.minimum } - if( valid_min && (value < valid_min)){ + if( value && valid_min && (value < valid_min)){ msg = "Line " + count + ": Column '" + key + "' out of range, value (" + value + ") < valid min (" + valid_min + ")"; @@ -370,7 +370,7 @@ if( header.dataType.maximum ){ valid_max = header.dataType.maximum } - if( valid_max && (value > valid_max)){ + if( value && valid_max && (value > valid_max)){ msg = "Line " + count + ": Column '" + key + "' out of range, value (" + value + ") > valid max (" + valid_max + ")"; status = 'error';