From 5fa9ec9b785cecb49b724f9fc89cd1cafb8e5fe5 Mon Sep 17 00:00:00 2001 From: Danny Parsons Date: Mon, 15 Mar 2021 14:13:55 +0000 Subject: [PATCH] fixes #6273 and file details shows for selected folder in subdialog --- instat/dlgOpenNetCDF.vb | 8 ++++++++ instat/static/InstatObject/R/stand_alone_functions.R | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/instat/dlgOpenNetCDF.vb b/instat/dlgOpenNetCDF.vb index a9c0eb14606..5a235db4149 100644 --- a/instat/dlgOpenNetCDF.vb +++ b/instat/dlgOpenNetCDF.vb @@ -200,6 +200,9 @@ Public Class dlgOpenNetCDF End If Else MsgBox("File type: '" & strFileExt & "' not recognised as a NetCDF file (.nc).", vbOKOnly) + strShort = "" + strMedium = "" + strLong = "" End If End If End Using @@ -239,12 +242,17 @@ Public Class dlgOpenNetCDF clsNcOpenFunction.ToScript(strTemp) frmMain.clsRLink.RunScript(strTemp, strComment:="Opening connection to first NetCDF file", bUpdateGrids:=False) bCloseFile = True + clsRFileDetails.AddParameter("infile", Chr(34) & Replace(strFiles(0), "\", "/") & Chr(34), iPosition:=1) clsImportNetcdfFunction.AddParameter("path", Chr(34) & Replace(strPath, "\", "/") & Chr(34)) ucrInputDataName.SetName(frmMain.clsRLink.MakeValidText(Path.GetFileName(strPath.TrimEnd(Path.DirectorySeparatorChar)))) + FileDetails() clsImportNetcdfFunction.RemoveParameterByName("boundary") clsBoundaryListFunction.ClearParameters() Else clsNcOpenFunction.RemoveParameterByName("filename") + strShort = "" + strMedium = "" + strLong = "" End If End If End Using diff --git a/instat/static/InstatObject/R/stand_alone_functions.R b/instat/static/InstatObject/R/stand_alone_functions.R index 6da23d05a76..0049bf76cd5 100644 --- a/instat/static/InstatObject/R/stand_alone_functions.R +++ b/instat/static/InstatObject/R/stand_alone_functions.R @@ -393,9 +393,9 @@ nc_as_data_frame <- function(nc, vars, keep_raw_time = TRUE, include_metadata = curr_count[2] <- 1 curr_dim_values[[y_var]] <- curr_dim_values[[y_var]][y_ind] if(show_requested_points) { - curr_dim_values[[paste0("requested_", x_var)]] <- lon_points[i] - curr_dim_values[[paste0("requested_", y_var)]] <- lat_points[i] - if(!is.null(id_points)) curr_dim_values[["requested_id"]] <- id_points[i] + curr_dim_values[[paste0(x_var, "_point")]] <- lon_points[i] + curr_dim_values[[paste0(y_var, "_point")]] <- lat_points[i] + if(!is.null(id_points)) curr_dim_values[["station"]] <- id_points[i] requested_points_added <- TRUE } @@ -444,14 +444,14 @@ nc_as_data_frame <- function(nc, vars, keep_raw_time = TRUE, include_metadata = time_ind <- which(raw_time_full %in% raw_time) units <- ncdf4::ncatt_get(nc, time_var, "units") if(units$hasatt && units$value == "julian_day") { - time_df[[paste0(time_var, "_date")]] <- as.Date(raw_time, origin = structure(-2440588, class = "Date")) + time_df[["date"]] <- as.Date(raw_time, origin = structure(-2440588, class = "Date")) } else { pcict_time <- ncdf4.helpers::nc.get.time.series(nc, time.dim.name = time_var) pcict_time <- pcict_time[time_ind] posixct_time <- PCICt::as.POSIXct.PCICt(pcict_time) - time_df[[paste0(time_var, "_full")]] <- posixct_time - time_df[[paste0(time_var, "_date")]] <- as.Date(posixct_time) + time_df[["date"]] <- as.Date(posixct_time) + time_df[["datetime"]] <- posixct_time } }) if(ncol(time_df) > 1) curr_var_data <- dplyr::full_join(curr_var_data, time_df, by = time_var)