Skip to content

Commit

Permalink
made station id compulsory
Browse files Browse the repository at this point in the history
  • Loading branch information
conlooptechnologies committed Aug 6, 2024
1 parent 0b1d5c0 commit a331ce3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 63 deletions.
86 changes: 43 additions & 43 deletions instat/sdgClimsoft.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions instat/sdgClimsoft.vb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Public Class sdgClimsoft

'Columns to include
'---------------------------------------
ucrChkIncludeStationId.SetText("Station Id")
ucrChkIncludeStationId.Enabled = False

ucrChkIncludeStationName.SetText("Station Name")
ucrChkIncludeStationName.Enabled = False

Expand All @@ -39,10 +42,6 @@ Public Class sdgClimsoft
ucrChkIncludeDateTime.SetText("Date Time")
ucrChkIncludeDateTime.Enabled = False

ucrChkIncludeStationId.SetText("Station Id")
ucrChkIncludeStationId.SetParameter(New RParameter("include_station_id", 13))
ucrChkIncludeStationId.SetRDefault("FALSE")

ucrChkIncludeElementId.SetText("Element Id")
ucrChkIncludeElementId.SetParameter(New RParameter("include_element_id", 14))
ucrChkIncludeElementId.SetRDefault("FALSE")
Expand Down Expand Up @@ -102,7 +101,6 @@ Public Class sdgClimsoft

'Columns
'---------------------------------------
ucrChkIncludeStationId.SetRCode(clsRFunction, bReset)
ucrChkIncludeElementId.SetRCode(clsRFunction, bReset)
ucrChkIncludeElementName.SetRCode(clsRFunction, bReset)
ucrChkIncludeAquistion.SetRCode(clsRFunction, bReset)
Expand Down
18 changes: 3 additions & 15 deletions instat/static/InstatObject/R/instat_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ DataBook$set("public", "import_climsoft_data", function(tableName,
station_filter_column, stations = c(),
element_filter_column, elements = c(),
qc_status = -1, start_date = NULL, end_date = NULL, unstack_data = FALSE,
include_station_id = FALSE, include_element_id = FALSE, include_element_name = FALSE,
include_element_id = FALSE, include_element_name = FALSE,
include_acquisition_type = FALSE, include_level = FALSE, include_entry_form = FALSE, include_captured_by = FALSE,
include_qc_status = FALSE, include_qc_log = FALSE, include_flag = FALSE,
import_selected_stations_metadata = FALSE, import_selected_elements_metadata = FALSE) {
Expand All @@ -1949,14 +1949,7 @@ DataBook$set("public", "import_climsoft_data", function(tableName,
#selects
#--------------------------------

sql_select<- ""

if(include_station_id){
sql_select <- paste0(tableName,".recordedFrom AS station_id")
sql_select <-paste0(sql_select,", station.stationName AS station_name")
}else{
sql_select <-"station.stationName AS station_name"
}
sql_select<- paste0(tableName,".recordedFrom AS station_id",", station.stationName AS station_name")

if(include_element_id){
sql_select <-paste0(sql_select, ", ", tableName,".describedBy AS element_id")
Expand Down Expand Up @@ -2059,19 +2052,14 @@ DataBook$set("public", "import_climsoft_data", function(tableName,
observations_df <- DBI::dbGetQuery(con, paste0(sql_select, sql_filter, sql_order_by))

# Convert station name and abbreviation columns to factor
columns_to_convert <- c("station_name", "element_abbrv")
columns_to_convert <- c("station_id", "station_name", "element_abbrv")
observations_df[columns_to_convert] <- lapply(observations_df[columns_to_convert], as.factor)

# Convert the date_time column to POSIXct (date-time) format
observations_df$date_time <- as.POSIXct(observations_df$date_time, format = "%Y-%m-%d %H:%M:%S")

# convert the date column to date format
observations_df$date <- as.Date(x = observations_df$date)
#observations_df$date <- as.Date(x = observations_df$date_time)

if(include_station_id){
observations_df$station_id <- as.factor(observations_df$station_id)
}

if(include_element_id){
observations_df$element_id <- as.factor(observations_df$element_id)
Expand Down

0 comments on commit a331ce3

Please sign in to comment.