diff --git a/src/main/java/edu/ie3/tools/Converter.java b/src/main/java/edu/ie3/tools/Converter.java index 9317209..9a396f0 100644 --- a/src/main/java/edu/ie3/tools/Converter.java +++ b/src/main/java/edu/ie3/tools/Converter.java @@ -125,14 +125,14 @@ private void convert() { ZonedDateTime newestPossibleModelrun = (ZonedDateTime) dbController.execSingleResultNamedQuery( - FileModel.NewestDownloadedModelrun, Collections.emptyList()); + FileModel.NEWEST_DOWNLOADED_MODELRUN, Collections.emptyList()); // retrieves the starting modelrun ( = oldest modelrun where persisted==false or no converter // run info available) ZonedDateTime currentModelrun = (ZonedDateTime) dbController.execSingleResultNamedQuery( - FileModel.OldestModelrunWithUnprocessedFiles, Collections.emptyList()); + FileModel.OLDEST_MODELRUN_WITH_UNPROCESSED_FILES, Collections.emptyList()); if (currentModelrun != null) { coordinates = getCoordinates(); @@ -195,11 +195,11 @@ private void openArchiveFiles(ZonedDateTime currentModelrun, int timestep) { FileModel.class, FileModel.createFileName(currentModelrun, timestep, param)); if (file != null) { files.add(file); - if (file.isSufficient_size() && (file.isValid_file() == null || file.isValid_file())) { - if (!file.isPersisted() && !file.isArchivefile_deleted() && !file.isDecompressed()) { + if (file.isSufficientSize() && (file.isValidFile() == null || file.isValidFile())) { + if (!file.isPersisted() && !file.isArchiveFileDeleted() && !file.isDecompressed()) { tasks.add(new Decompressor(file, folderpath)); } - } else if (file.getDownload_fails() > 3 + } else if (file.getDownloadFails() > 3 || file.getModelrun().isBefore(ZonedDateTime.now().minusDays(1))) { if (edu.ie3.tools.Main.deleteDownloadedFiles) { logger.trace( @@ -224,10 +224,10 @@ private void openArchiveFiles(ZonedDateTime currentModelrun, int timestep) { } files.forEach( file -> { - if (file.isDecompressed() && (file.isValid_file() == null || file.isValid_file())) + if (file.isDecompressed() && (file.isValidFile() == null || file.isValidFile())) parameterLevelToFile.put(file.getParameter(), file); else { - file.setValid_file(false); + file.setValidFile(false); fileStatusLogger.trace( file.getName() + " | vff | valid_file = false | Decompression failed"); } @@ -301,10 +301,10 @@ public void convertTimeStep(ZonedDateTime modelRun, int timeStep, String folderP // update the file model information about the validity of the extractor result FileModel file = parameterLevelToFile.get(extractorResult.getParameter()); - file.setValid_file(extractorResult.isValidFile()); + file.setValidFile(extractorResult.isValidFile()); fileStatusLogger.trace( file.getName() - + (Boolean.TRUE.equals(file.isValid_file()) + + (Boolean.TRUE.equals(file.isValidFile()) ? " | vft | valid_file = true | Extraction" : " | vff | valid_file = false | Extraction")); @@ -377,7 +377,7 @@ private void validation() { for (Map.Entry entry : parameterLevelToFile.entrySet()) { FileModel file = entry.getValue(); double relAmountMissingCoordinates = - ((double) file.getMissing_coordinates()) / coordinates.size(); + ((double) file.getMissingCoordinates()) / coordinates.size(); if (relAmountMissingCoordinates < edu.ie3.tools.Main.faultTolerance) { file.setPersisted(true); fileStatusLogger.trace(file.getName() + " | pf | persisted = true | Validation"); diff --git a/src/main/java/edu/ie3/tools/Decompressor.java b/src/main/java/edu/ie3/tools/Decompressor.java index 0badf15..751d47b 100644 --- a/src/main/java/edu/ie3/tools/Decompressor.java +++ b/src/main/java/edu/ie3/tools/Decompressor.java @@ -53,7 +53,7 @@ public static boolean decompress(@NotNull FileModel file, String folderpath) { Parameter parameter = file.getParameter(); logger.warn( Converter.getFormattedTimestep(file) + "File not found for parameter " + parameter); - file.setArchivefile_deleted(true); + file.setArchiveFileDeleted(true); filestatusLogger.trace( file.getName() + " | adt | archivefile_deleted = true | File not Found"); diff --git a/src/main/java/edu/ie3/tools/Downloader.java b/src/main/java/edu/ie3/tools/Downloader.java index 5d2ec3e..b9f8c2f 100644 --- a/src/main/java/edu/ie3/tools/Downloader.java +++ b/src/main/java/edu/ie3/tools/Downloader.java @@ -97,7 +97,7 @@ public void run() { ZonedDateTime newestDateDownloaded = earliestPossibleModelrun; List failedDownloads = dbController.execNamedQuery( - FileModel.FailedDownloads, Collections.singletonList(earliestPossibleModelrun)); + FileModel.FAILED_DOWNLOADS, Collections.singletonList(earliestPossibleModelrun)); for (FileModel file : failedDownloads) { ZonedDateTime modelrun = file.getModelrun(); if (modelrun.isAfter(newestDateDownloaded)) { @@ -183,7 +183,7 @@ public boolean download(ZonedDateTime modelrun, Parameter param) { */ public boolean downloadFile(String folder, FileModel filemodel) { boolean success = false; - if (!filemodel.isSufficient_size() && filemodel.getDownload_fails() < 3) { + if (!filemodel.isSufficientSize() && filemodel.getDownloadFails() < 3) { String url = filemodel.getURL(); try { if (isUrlReachable(url)) { @@ -195,15 +195,15 @@ public boolean downloadFile(String folder, FileModel filemodel) { success = false; logger.warn("File " + filemodel.getName() + " is too small (" + file.length() + "B)"); } else { - filemodel.setSufficient_size(true); + filemodel.setSufficientSize(true); filestatusLogger.trace( file.getName() + " | ss | sufficient_size = true | Download success"); - filemodel.setDownload_date(ZonedDateTime.now()); + filemodel.setDownloadDate(ZonedDateTime.now()); filestatusLogger.trace( file.getName() + " | dd | Downloadd_date = now | Download success"); - filemodel.setArchivefile_deleted(false); + filemodel.setArchiveFileDeleted(false); filestatusLogger.trace( file.getName() + " | adf | archivefile_deleted = false | Download success"); success = true; @@ -215,7 +215,7 @@ public boolean downloadFile(String folder, FileModel filemodel) { logger.error("Could not download " + filemodel.getName() + " (" + e.getMessage() + ")"); } if (!success) { - filemodel.incrementDownload_fails(); + filemodel.incrementDownloadFails(); filestatusLogger.trace( filemodel.getName() + " | idf | incremented download_fails | failed Download"); } diff --git a/src/main/java/edu/ie3/tools/Extractor.java b/src/main/java/edu/ie3/tools/Extractor.java index 4191312..4fdadb9 100644 --- a/src/main/java/edu/ie3/tools/Extractor.java +++ b/src/main/java/edu/ie3/tools/Extractor.java @@ -146,9 +146,9 @@ private ExtractorResult extractParameters() throws IOException { // check if file exists in path File f = file.getGRIB22File(path); if (!f.exists()) { - file.setGribfile_deleted(true); + file.setGribFileDeleted(true); f = file.getBZ2File(path); - if (!f.exists()) file.setArchivefile_deleted(true); + if (!f.exists()) file.setArchiveFileDeleted(true); throw new IOException( "Could not find file " + file.getName() + " ( " + f.getAbsolutePath() + " )"); } diff --git a/src/main/java/edu/ie3/tools/models/persistence/FileModel.java b/src/main/java/edu/ie3/tools/models/persistence/FileModel.java index ba4f6e9..f1f29cf 100644 --- a/src/main/java/edu/ie3/tools/models/persistence/FileModel.java +++ b/src/main/java/edu/ie3/tools/models/persistence/FileModel.java @@ -39,17 +39,17 @@ public class FileModel implements Serializable { /** Selects newest (max) modelrun */ - public static final String NewestDownloadedModelrun = "FileModel.NewestDownloadedModelrun"; + public static final String NEWEST_DOWNLOADED_MODELRUN = "FileModel.NewestDownloadedModelrun"; /** * Selects the oldest (min) modelrun, which has a sufficient file size, but hasn't been processed * yet */ - public static final String OldestModelrunWithUnprocessedFiles = + public static final String OLDEST_MODELRUN_WITH_UNPROCESSED_FILES = "FileModel.OldestModelrunWithUnprocessedFiles"; /** Selects files, that have been too small or invalid in previous runs */ - public static final String FailedDownloads = "FileModel.FailedDownloads"; + public static final String FAILED_DOWNLOADS = "FileModel.FailedDownloads"; /** Selects files, that are invalid and not yet deleted */ - public static final String InvalidFiles = "FileModel.InvalidFiles"; + public static final String INVALID_FILES = "FileModel.InvalidFiles"; public static final String PREFIX = "icon-eu_europe_regular-lat-lon_"; public static final String PREFIX_SINGLE_LEVEL = PREFIX + "single-level_"; @@ -69,23 +69,30 @@ public class FileModel implements Serializable { @Enumerated(EnumType.STRING) private Parameter parameter; - @Column private int download_fails; + @Column(name = "download_fails") + private int downloadFails; - @Column private boolean sufficient_size; + @Column(name = "sufficient_size") + private boolean sufficientSize; - @Column private ZonedDateTime download_date; + @Column(name = "download_date") + private ZonedDateTime downloadDate; @Column private boolean decompressed; - @Column private int missing_coordinates; + @Column(name = "missing_coordinates") + private int missingCoordinates; - @Column private Boolean valid_file; + @Column(name = "valid_file") + private Boolean validFile; @Column private boolean persisted; - @Column private boolean archivefile_deleted; + @Column(name = "archivefile_deleted") + private boolean archiveFileDeleted; - @Column private boolean gribfile_deleted; + @Column(name = "gribfile_deleted") + private boolean isGribFileDeleted; public FileModel(ZonedDateTime modelrun, int timestep, Parameter parameter) { this.modelrun = modelrun; @@ -134,32 +141,32 @@ public void setParameter(Parameter parameter) { this.parameter = parameter; } - public int getDownload_fails() { - return download_fails; + public int getDownloadFails() { + return downloadFails; } - public void setDownload_fails(int download_fails) { - this.download_fails = download_fails; + public void setDownloadFails(int download_fails) { + this.downloadFails = download_fails; } - public void incrementDownload_fails() { - this.download_fails++; + public void incrementDownloadFails() { + this.downloadFails++; } - public boolean isSufficient_size() { - return sufficient_size; + public boolean isSufficientSize() { + return sufficientSize; } - public void setSufficient_size(boolean sufficient_size) { - this.sufficient_size = sufficient_size; + public void setSufficientSize(boolean sufficient_size) { + this.sufficientSize = sufficient_size; } - public ZonedDateTime getDownload_date() { - return download_date; + public ZonedDateTime getDownloadDate() { + return downloadDate; } - public void setDownload_date(ZonedDateTime download_date) { - this.download_date = download_date; + public void setDownloadDate(ZonedDateTime download_date) { + this.downloadDate = download_date; } public boolean isDecompressed() { @@ -170,24 +177,24 @@ public void setDecompressed(boolean decompressed) { this.decompressed = decompressed; } - public int getMissing_coordinates() { - return missing_coordinates; + public int getMissingCoordinates() { + return missingCoordinates; } - public void setMissing_coordinates(int missing_coordinates) { - this.missing_coordinates = missing_coordinates; + public void setMissingCoordinates(int missingCoordinates) { + this.missingCoordinates = missingCoordinates; } - public void addMissing_coordinate() { - this.missing_coordinates++; + public void addMissingCoordinate() { + this.missingCoordinates++; } - public Boolean isValid_file() { - return valid_file; + public Boolean isValidFile() { + return validFile; } - public void setValid_file(Boolean valid_file) { - this.valid_file = valid_file; + public void setValidFile(Boolean valid_file) { + this.validFile = valid_file; } public boolean isPersisted() { @@ -198,20 +205,20 @@ public void setPersisted(boolean persisted) { this.persisted = persisted; } - public boolean isArchivefile_deleted() { - return archivefile_deleted; + public boolean isArchiveFileDeleted() { + return archiveFileDeleted; } - public void setArchivefile_deleted(boolean archivefile_deleted) { - this.archivefile_deleted = archivefile_deleted; + public void setArchiveFileDeleted(boolean archiveFileDeleted) { + this.archiveFileDeleted = archiveFileDeleted; } - public boolean isGribfile_deleted() { - return gribfile_deleted; + public boolean isGribFileDeleted() { + return isGribFileDeleted; } - public void setGribfile_deleted(boolean gribfile_deleted) { - this.gribfile_deleted = gribfile_deleted; + public void setGribFileDeleted(boolean isGribFileDeleted) { + this.isGribFileDeleted = isGribFileDeleted; } public void setModelrun(ZonedDateTime modelrun) { diff --git a/src/main/java/edu/ie3/tools/models/persistence/ICONWeatherModel.java b/src/main/java/edu/ie3/tools/models/persistence/ICONWeatherModel.java index 71fb02f..7608e6d 100644 --- a/src/main/java/edu/ie3/tools/models/persistence/ICONWeatherModel.java +++ b/src/main/java/edu/ie3/tools/models/persistence/ICONWeatherModel.java @@ -30,47 +30,47 @@ public class ICONWeatherModel implements Serializable { /** Albedo in % */ @Column(name = "alb_rad") - private Double alb_rad; + private Double albRad; /** Net short-wave radiation flux at surface in W/m² */ @Column(name = "asob_s") - private Double asob_s; + private Double asobS; /** Surface down solar diffuse radiation in W/m² */ @Column(name = "aswdifd_s") - private Double aswdifd_s; + private Double aswdifdS; /** Surface up diffuse radiation in W/m² */ @Column(name = "aswdifu_s") - private Double aswdifu_s; + private Double aswdifuS; /** Direct radiation in W/m² */ @Column(name = "aswdir_s") - private Double aswdirs_s; + private Double aswdirS; /** Net short-wave radiation flux at surface (instantaneous) in W/m² */ @Column(name = "sobs_rad") - private Double sobs_rad; + private Double sobsRad; /** Temperature at 131m above ground in K */ @Column(name = "t_131m") - private Double t_131m; + private Double t131m; /** Temperature at 2m above ground in K */ @Column(name = "t_2m") - private Double t_2m; + private Double t2m; /** Ground temperature in K */ @Column(name = "t_g") - private Double t_g; + private Double tG; /** Zonal wind at 10m above ground in m/s */ @Column(name = "u_10m") - private Double u_10m; + private Double u10m; /** Meridional wind at 10m above ground in m/s */ @Column(name = "v_10m") - private Double v_10m; + private Double v10m; /** Surface roughness in m */ @Column(name = "z0") @@ -78,63 +78,63 @@ public class ICONWeatherModel implements Serializable { /** Pressure at 20m above ground in Pa */ @Column(name = "p_20m") - private Double p_20m; + private Double p20m; /** Pressure at 65m above ground in Pa */ @Column(name = "p_65m") - private Double p_65m; + private Double p65m; /** Pressure at 131m above ground in Pa */ @Column(name = "p_131m") - private Double p_131m; + private Double p131m; /** Zonal wind at 20m above ground in m/s */ @Column(name = "u_20m") - private Double u_20m; + private Double u20m; /** Meridional wind at 20m above ground in m/s */ @Column(name = "v_20m") - private Double v_20m; + private Double v20m; /** Vertical wind at 20m above ground in m/s */ @Column(name = "w_20m") - private Double w_20m; + private Double w20m; /** Zonal wind at 65m above ground in m/s */ @Column(name = "u_65m") - private Double u_65m; + private Double u65m; /** Meridional wind at 65m above ground in m/s */ @Column(name = "v_65m") - private Double v_65m; + private Double v65m; /** Vertical wind at 65m above ground in m/s */ @Column(name = "w_65m") - private Double w_65m; + private Double w65m; /** Zonal wind at 131m above ground in m/s */ @Column(name = "u_131m") - private Double u_131m; + private Double u131m; /** Meridional wind at 131m above ground in m/s */ @Column(name = "v_131m") - private Double v_131m; + private Double v131m; /** Vertical wind at 131m above ground in m/s */ @Column(name = "w_131m") - private Double w_131m; + private Double w131m; /** Zonal wind at 216m above ground in m/s */ @Column(name = "u_216m") - private Double u_216m; + private Double u216m; /** Meridional wind at 216m above ground in m/s */ @Column(name = "v_216m") - private Double v_216m; + private Double v216m; /** Vertical wind at 216m above ground in m/s */ @Column(name = "w_216m") - private Double w_216m; + private Double w216m; public ICONWeatherModel() {} @@ -170,16 +170,17 @@ public static String getSQLUpsertStatement(Collection entities } public static String getSQLUpsertStatement( - Collection entities, String database_schema) { + Collection entities, String databaseSchema) { StringBuilder upsertStatementBuilder = new StringBuilder(); - upsertStatementBuilder.append( - "INSERT INTO " - + database_schema - + ".weather(\n" - + "\tdatum, alb_rad, asob_s, aswdifd_s, aswdifu_s, aswdir_s, sobs_rad, p_20m, p_65m, p_131m, t_131m, t_2m, t_g, u_10m, u_131m, u_20m, u_216m, u_65m, v_10m, v_131m, v_20m, v_216m, v_65m, w_131m, w_20m, w_216m, w_65m, z0, coordinate_id)\n" - + "\t VALUES "); + upsertStatementBuilder + .append("INSERT INTO ") + .append(databaseSchema) + .append(".weather(\n") + .append( + "\tdatum, alb_rad, asob_s, aswdifd_s, aswdifu_s, aswdir_s, sobs_rad, p_20m, p_65m, p_131m, t_131m, t_2m, t_g, u_10m, u_131m, u_20m, u_216m, u_65m, v_10m, v_131m, v_20m, v_216m, v_65m, w_131m, w_20m, w_216m, w_65m, z0, coordinate_id)\n") + .append("\t VALUES "); entities.forEach( - entity -> upsertStatementBuilder.append(entity.getSQLInsertValuesString() + ", ")); + entity -> upsertStatementBuilder.append(entity.getSQLInsertValuesString()).append(", ")); int lastComma = upsertStatementBuilder.lastIndexOf(","); upsertStatementBuilder.deleteCharAt(lastComma); upsertStatementBuilder.append("ON CONFLICT (coordinate_id, datum) DO UPDATE \n" + " SET "); @@ -224,76 +225,76 @@ public void setDate(ZonedDateTime date) { this.date = date; } - public Double getAlb_rad() { - return alb_rad; + public Double getAlbRad() { + return albRad; } - public void setAlb_rad(Double alb_rad) { - this.alb_rad = alb_rad; + public void setAlbRad(Double albRad) { + this.albRad = albRad; } - public Double getAsob_s() { - return asob_s; + public Double getAsobS() { + return asobS; } - public void setAsob_s(Double asob_s) { - this.asob_s = asob_s; + public void setAsobS(Double asobS) { + this.asobS = asobS; } - public Double getAswdifd_s() { - return aswdifd_s; + public Double getAswdifdS() { + return aswdifdS; } - public void setAswdifd_s(Double aswdifd_s) { - this.aswdifd_s = aswdifd_s; + public void setAswdifdS(Double aswdifdS) { + this.aswdifdS = aswdifdS; } - public Double getAswdifu_s() { - return aswdifu_s; + public Double getAswdifuS() { + return aswdifuS; } - public void setAswdifu_s(Double aswdifu_s) { - this.aswdifu_s = aswdifu_s; + public void setAswdifuS(Double aswdifuS) { + this.aswdifuS = aswdifuS; } - public Double getAswdirs_s() { - return aswdirs_s; + public Double getAswdirS() { + return aswdirS; } - public void setAswdirs_s(Double aswdirs_s) { - this.aswdirs_s = aswdirs_s; + public void setAswdirS(Double aswdirsS) { + this.aswdirS = aswdirsS; } - public Double getT_2m() { - return t_2m; + public Double getT2m() { + return t2m; } - public void setT_2m(Double t_2m) { - this.t_2m = t_2m; + public void setT2m(Double t2m) { + this.t2m = t2m; } - public Double getT_g() { - return t_g; + public Double getTG() { + return tG; } - public void setT_g(Double t_g) { - this.t_g = t_g; + public void setTG(Double tG) { + this.tG = tG; } - public Double getU_10m() { - return u_10m; + public Double getU10m() { + return u10m; } - public void setU_10m(Double u_10m) { - this.u_10m = u_10m; + public void setU10m(Double u10m) { + this.u10m = u10m; } - public Double getV_10m() { - return v_10m; + public Double getV10m() { + return v10m; } - public void setV_10m(Double v_10m) { - this.v_10m = v_10m; + public void setV10m(Double v10m) { + this.v10m = v10m; } public Double getZ0() { @@ -304,140 +305,140 @@ public void setZ0(Double z0) { this.z0 = z0; } - public Double getU_20m() { - return u_20m; + public Double getU20m() { + return u20m; } - public void setU_20m(Double u_20m) { - this.u_20m = u_20m; + public void setU20m(Double u20m) { + this.u20m = u20m; } - public Double getV_20m() { - return v_20m; + public Double getV20m() { + return v20m; } - public void setV_20m(Double v_20m) { - this.v_20m = v_20m; + public void setV20m(Double v20m) { + this.v20m = v20m; } - public Double getW_20m() { - return w_20m; + public Double getW20m() { + return w20m; } - public void setW_20m(Double w_20m) { - this.w_20m = w_20m; + public void setW20m(Double w20m) { + this.w20m = w20m; } - public Double getU_65m() { - return u_65m; + public Double getU65m() { + return u65m; } - public void setU_65m(Double u_65m) { - this.u_65m = u_65m; + public void setU65m(Double u65m) { + this.u65m = u65m; } - public Double getV_65m() { - return v_65m; + public Double getV65m() { + return v65m; } - public void setV_65m(Double v_65m) { - this.v_65m = v_65m; + public void setV65m(Double v65m) { + this.v65m = v65m; } - public Double getW_65m() { - return w_65m; + public Double getW65m() { + return w65m; } - public void setW_65m(Double w_65m) { - this.w_65m = w_65m; + public void setW65m(Double w65m) { + this.w65m = w65m; } - public Double getU_216m() { - return u_216m; + public Double getU216m() { + return u216m; } - public void setU_216m(Double u_216m) { - this.u_216m = u_216m; + public void setU216m(Double u216m) { + this.u216m = u216m; } - public Double getV_216m() { - return v_216m; + public Double getV216m() { + return v216m; } - public void setV_216m(Double v_216m) { - this.v_216m = v_216m; + public void setV216m(Double v216m) { + this.v216m = v216m; } - public Double getW_216m() { - return w_216m; + public Double getW216m() { + return w216m; } - public void setW_216m(Double w_216m) { - this.w_216m = w_216m; + public void setW216m(Double w216m) { + this.w216m = w216m; } - public Double getU_131m() { - return u_131m; + public Double getU131m() { + return u131m; } - public void setU_131m(Double u_131m) { - this.u_131m = u_131m; + public void setU131m(Double u131m) { + this.u131m = u131m; } - public Double getV_131m() { - return v_131m; + public Double getV131m() { + return v131m; } - public void setV_131m(Double v_131m) { - this.v_131m = v_131m; + public void setV131m(Double v131m) { + this.v131m = v131m; } - public Double getW_131m() { - return w_131m; + public Double getW131m() { + return w131m; } - public void setW_131m(Double w_131m) { - this.w_131m = w_131m; + public void setW131m(Double w131m) { + this.w131m = w131m; } - public Double getSobs_rad() { - return sobs_rad; + public Double getSobsRad() { + return sobsRad; } - public void setSobs_rad(Double sobs_rad) { - this.sobs_rad = sobs_rad; + public void setSobsRad(Double sobsRad) { + this.sobsRad = sobsRad; } - public Double getT_131m() { - return t_131m; + public Double getT131m() { + return t131m; } - public void setT_131m(Double t_131m) { - this.t_131m = t_131m; + public void setT131m(Double t131m) { + this.t131m = t131m; } - public Double getP_20m() { - return p_20m; + public Double getP20m() { + return p20m; } - public void setP_20m(Double p_20m) { - this.p_20m = p_20m; + public void setP20m(Double p20m) { + this.p20m = p20m; } - public Double getP_65m() { - return p_65m; + public Double getP65m() { + return p65m; } - public void setP_65m(Double p_65m) { - this.p_65m = p_65m; + public void setP65m(Double p65m) { + this.p65m = p65m; } - public Double getP_131m() { - return p_131m; + public Double getP131m() { + return p131m; } - public void setP_131m(Double p_131m) { - this.p_131m = p_131m; + public void setP131m(Double p131m) { + this.p131m = p131m; } public void setParameter(Parameter param, Double value) { @@ -445,34 +446,34 @@ public void setParameter(Parameter param, Double value) { switch (param) { // Single Level Params case ALBEDO: - alb_rad = value; + albRad = value; break; case ASOB_S: - asob_s = value; + asobS = value; break; case DIFS_D: - aswdifd_s = value; + aswdifdS = value; break; case DIFS_U: - aswdifu_s = value; + aswdifuS = value; break; case DIRS: - aswdirs_s = value; + aswdirS = value; break; case SOBS_RAD: - sobs_rad = value; + sobsRad = value; break; case T_2M: - t_2m = value; + t2m = value; break; case T_G: - t_g = value; + tG = value; break; case U_10M: - u_10m = value; + u10m = value; break; case V_10M: - v_10m = value; + v10m = value; break; case Z0: z0 = value; @@ -480,56 +481,56 @@ public void setParameter(Parameter param, Double value) { // Matrix Level Params case P_20M: - p_20m = value; + p20m = value; break; case P_65M: - p_65m = value; + p65m = value; break; case P_131M: - p_131m = value; + p131m = value; break; case T_131M: - t_131m = value; + t131m = value; break; case U_20M: - u_20m = value; + u20m = value; break; case U_65M: - u_65m = value; + u65m = value; break; case U_131M: - u_131m = value; + u131m = value; break; case U_216M: - u_216m = value; + u216m = value; break; case V_20M: - v_20m = value; + v20m = value; break; case V_65M: - v_65m = value; + v65m = value; break; case V_131M: - v_131m = value; + v131m = value; break; case V_216M: - v_216m = value; + v216m = value; break; case W_20M: - w_20m = value; + w20m = value; break; case W_65M: - w_65m = value; + w65m = value; break; case W_131M: - w_131m = value; + w131m = value; break; case W_216M: - w_216m = value; + w216m = value; break; } } @@ -538,65 +539,65 @@ public Double getParameter(Parameter param) { switch (param) { // Singlelevel Parameter case ALBEDO: - return alb_rad; + return albRad; case ASOB_S: - return asob_s; + return asobS; case DIFS_D: - return aswdifd_s; + return aswdifdS; case DIFS_U: - return aswdifu_s; + return aswdifuS; case DIRS: - return aswdirs_s; + return aswdirS; case SOBS_RAD: - return sobs_rad; + return sobsRad; case T_2M: - return t_2m; + return t2m; case T_G: - return t_g; + return tG; case U_10M: - return u_10m; + return u10m; case V_10M: - return v_10m; + return v10m; case Z0: return z0; // Multilevel parameters case U_20M: - return u_20m; + return u20m; case U_65M: - return u_65m; + return u65m; case U_131M: - return u_131m; + return u131m; case U_216M: - return u_216m; + return u216m; case P_20M: - return p_20m; + return p20m; case P_65M: - return p_65m; + return p65m; case P_131M: - return p_131m; + return p131m; case T_131M: - return t_131m; + return t131m; case V_20M: - return v_20m; + return v20m; case V_65M: - return v_65m; + return v65m; case V_131M: - return v_131m; + return v131m; case V_216M: - return v_216m; + return v216m; case W_20M: - return w_20m; + return w20m; case W_65M: - return w_65m; + return w65m; case W_131M: - return w_131m; + return w131m; case W_216M: - return w_216m; + return w216m; default: return null; @@ -609,34 +610,34 @@ public void interpolateParameter(Parameter param, double interpolationRatio, Dou switch (param) { // Single Level Params case ALBEDO: - alb_rad = interpolationCalculation(alb_rad, value, interpolationRatio); + albRad = interpolationCalculation(albRad, value, interpolationRatio); break; case ASOB_S: - asob_s = interpolationCalculation(asob_s, value, interpolationRatio); + asobS = interpolationCalculation(asobS, value, interpolationRatio); break; case DIFS_D: - aswdifd_s = interpolationCalculation(aswdifd_s, value, interpolationRatio); + aswdifdS = interpolationCalculation(aswdifdS, value, interpolationRatio); break; case DIFS_U: - aswdifu_s = interpolationCalculation(aswdifu_s, value, interpolationRatio); + aswdifuS = interpolationCalculation(aswdifuS, value, interpolationRatio); break; case DIRS: - aswdirs_s = interpolationCalculation(aswdirs_s, value, interpolationRatio); + aswdirS = interpolationCalculation(aswdirS, value, interpolationRatio); break; case SOBS_RAD: - sobs_rad = interpolationCalculation(sobs_rad, value, interpolationRatio); + sobsRad = interpolationCalculation(sobsRad, value, interpolationRatio); break; case T_2M: - t_2m = interpolationCalculation(t_2m, value, interpolationRatio); + t2m = interpolationCalculation(t2m, value, interpolationRatio); break; case T_G: - t_g = interpolationCalculation(t_g, value, interpolationRatio); + tG = interpolationCalculation(tG, value, interpolationRatio); break; case U_10M: - u_10m = interpolationCalculation(u_10m, value, interpolationRatio); + u10m = interpolationCalculation(u10m, value, interpolationRatio); break; case V_10M: - v_10m = interpolationCalculation(v_10m, value, interpolationRatio); + v10m = interpolationCalculation(v10m, value, interpolationRatio); break; case Z0: z0 = interpolationCalculation(z0, value, interpolationRatio); @@ -644,56 +645,56 @@ public void interpolateParameter(Parameter param, double interpolationRatio, Dou // Matrix Type Params case P_20M: - p_20m = interpolationCalculation(p_20m, value, interpolationRatio); + p20m = interpolationCalculation(p20m, value, interpolationRatio); break; case P_65M: - p_65m = interpolationCalculation(p_65m, value, interpolationRatio); + p65m = interpolationCalculation(p65m, value, interpolationRatio); break; case P_131M: - p_131m = interpolationCalculation(p_131m, value, interpolationRatio); + p131m = interpolationCalculation(p131m, value, interpolationRatio); break; case T_131M: - t_131m = interpolationCalculation(t_131m, value, interpolationRatio); + t131m = interpolationCalculation(t131m, value, interpolationRatio); break; case U_20M: - u_20m = interpolationCalculation(u_20m, value, interpolationRatio); + u20m = interpolationCalculation(u20m, value, interpolationRatio); break; case U_65M: - u_65m = interpolationCalculation(u_65m, value, interpolationRatio); + u65m = interpolationCalculation(u65m, value, interpolationRatio); break; case U_131M: - u_131m = interpolationCalculation(u_131m, value, interpolationRatio); + u131m = interpolationCalculation(u131m, value, interpolationRatio); break; case U_216M: - u_216m = interpolationCalculation(u_216m, value, interpolationRatio); + u216m = interpolationCalculation(u216m, value, interpolationRatio); break; case V_20M: - v_20m = interpolationCalculation(v_20m, value, interpolationRatio); + v20m = interpolationCalculation(v20m, value, interpolationRatio); break; case V_65M: - v_65m = interpolationCalculation(v_65m, value, interpolationRatio); + v65m = interpolationCalculation(v65m, value, interpolationRatio); break; case V_131M: - v_131m = interpolationCalculation(v_131m, value, interpolationRatio); + v131m = interpolationCalculation(v131m, value, interpolationRatio); break; case V_216M: - v_216m = interpolationCalculation(v_216m, value, interpolationRatio); + v216m = interpolationCalculation(v216m, value, interpolationRatio); break; case W_20M: - w_20m = interpolationCalculation(w_20m, value, interpolationRatio); + w20m = interpolationCalculation(w20m, value, interpolationRatio); break; case W_65M: - w_65m = interpolationCalculation(w_65m, value, interpolationRatio); + w65m = interpolationCalculation(w65m, value, interpolationRatio); break; case W_131M: - w_131m = interpolationCalculation(w_131m, value, interpolationRatio); + w131m = interpolationCalculation(w131m, value, interpolationRatio); break; case W_216M: - w_216m = interpolationCalculation(w_216m, value, interpolationRatio); + w216m = interpolationCalculation(w216m, value, interpolationRatio); break; } } @@ -721,32 +722,32 @@ public void setCoordinate(CoordinateModel coordinate) { public String getSQLInsertValuesString() { String insertValues = "("; insertValues += "'" + ConfigurationParameters.SQL_FORMATTER(date) + "', "; - insertValues += alb_rad + ", "; - insertValues += asob_s + ", "; - insertValues += aswdifd_s + ", "; - insertValues += aswdifu_s + ", "; - insertValues += aswdirs_s + ", "; - insertValues += sobs_rad + ", "; - insertValues += p_20m + ", "; - insertValues += p_65m + ", "; - insertValues += p_131m + ", "; - insertValues += t_131m + ", "; - insertValues += t_2m + ", "; - insertValues += t_g + ", "; - insertValues += u_10m + ", "; - insertValues += u_131m + ", "; - insertValues += u_20m + ", "; - insertValues += u_216m + ", "; - insertValues += u_65m + ", "; - insertValues += v_10m + ", "; - insertValues += v_131m + ", "; - insertValues += v_20m + ", "; - insertValues += v_216m + ", "; - insertValues += v_65m + ", "; - insertValues += w_131m + ", "; - insertValues += w_20m + ", "; - insertValues += w_216m + ", "; - insertValues += w_65m + ", "; + insertValues += albRad + ", "; + insertValues += asobS + ", "; + insertValues += aswdifdS + ", "; + insertValues += aswdifuS + ", "; + insertValues += aswdirS + ", "; + insertValues += sobsRad + ", "; + insertValues += p20m + ", "; + insertValues += p65m + ", "; + insertValues += p131m + ", "; + insertValues += t131m + ", "; + insertValues += t2m + ", "; + insertValues += tG + ", "; + insertValues += u10m + ", "; + insertValues += u131m + ", "; + insertValues += u20m + ", "; + insertValues += u216m + ", "; + insertValues += u65m + ", "; + insertValues += v10m + ", "; + insertValues += v131m + ", "; + insertValues += v20m + ", "; + insertValues += v216m + ", "; + insertValues += v65m + ", "; + insertValues += w131m + ", "; + insertValues += w20m + ", "; + insertValues += w216m + ", "; + insertValues += w65m + ", "; insertValues += z0 + ", "; insertValues += coordinate.getId(); insertValues += ")"; @@ -758,15 +759,13 @@ public String getSQLInsertValuesString() { * refer to: * https://stackoverflow.com/questions/3107044/preparedstatement-with-list-of-parameters-in-a-in-clause */ - public static String getPSQLFindString(String database_schema) { - String query = - "SELECT * FROM " - + database_schema - + ".weather w JOIN " - + database_schema - + ".icon_coordinates c ON w.coordinate_id = c.id " - + "WHERE datum=? AND coordinate_id = ANY(?);"; - return query; + public static String getPSQLFindString(String databaseSchema) { + return "SELECT * FROM " + + databaseSchema + + ".weather w JOIN " + + databaseSchema + + ".icon_coordinates c ON w.coordinate_id = c.id " + + "WHERE datum=? AND coordinate_id = ANY(?);"; } @Override @@ -776,33 +775,33 @@ public boolean equals(Object o) { ICONWeatherModel that = (ICONWeatherModel) o; return Objects.equals(date, that.date) && Objects.equals(coordinate, that.coordinate) - && Objects.equals(alb_rad, that.alb_rad) - && Objects.equals(asob_s, that.asob_s) - && Objects.equals(aswdifd_s, that.aswdifd_s) - && Objects.equals(aswdifu_s, that.aswdifu_s) - && Objects.equals(aswdirs_s, that.aswdirs_s) - && Objects.equals(sobs_rad, that.sobs_rad) - && Objects.equals(p_20m, that.p_20m) - && Objects.equals(p_65m, that.p_65m) - && Objects.equals(p_131m, that.p_131m) - && Objects.equals(t_131m, that.t_131m) - && Objects.equals(t_2m, that.t_2m) - && Objects.equals(t_g, that.t_g) - && Objects.equals(u_10m, that.u_10m) - && Objects.equals(v_10m, that.v_10m) + && Objects.equals(albRad, that.albRad) + && Objects.equals(asobS, that.asobS) + && Objects.equals(aswdifdS, that.aswdifdS) + && Objects.equals(aswdifuS, that.aswdifuS) + && Objects.equals(aswdirS, that.aswdirS) + && Objects.equals(sobsRad, that.sobsRad) + && Objects.equals(p20m, that.p20m) + && Objects.equals(p65m, that.p65m) + && Objects.equals(p131m, that.p131m) + && Objects.equals(t131m, that.t131m) + && Objects.equals(t2m, that.t2m) + && Objects.equals(tG, that.tG) + && Objects.equals(u10m, that.u10m) + && Objects.equals(v10m, that.v10m) && Objects.equals(z0, that.z0) - && Objects.equals(u_20m, that.u_20m) - && Objects.equals(v_20m, that.v_20m) - && Objects.equals(w_20m, that.w_20m) - && Objects.equals(u_65m, that.u_65m) - && Objects.equals(v_65m, that.v_65m) - && Objects.equals(w_65m, that.w_65m) - && Objects.equals(u_131m, that.u_131m) - && Objects.equals(v_131m, that.v_131m) - && Objects.equals(w_131m, that.w_131m) - && Objects.equals(u_216m, that.u_216m) - && Objects.equals(v_216m, that.v_216m) - && Objects.equals(w_216m, that.w_216m); + && Objects.equals(u20m, that.u20m) + && Objects.equals(v20m, that.v20m) + && Objects.equals(w20m, that.w20m) + && Objects.equals(u65m, that.u65m) + && Objects.equals(v65m, that.v65m) + && Objects.equals(w65m, that.w65m) + && Objects.equals(u131m, that.u131m) + && Objects.equals(v131m, that.v131m) + && Objects.equals(w131m, that.w131m) + && Objects.equals(u216m, that.u216m) + && Objects.equals(v216m, that.v216m) + && Objects.equals(w216m, that.w216m); } @Override @@ -818,59 +817,59 @@ public String toString() { + "\n, coordinate=" + coordinate + ", alb_rad=" - + alb_rad + + albRad + ", asob_s=" - + asob_s + + asobS + ", aswdifd_s=" - + aswdifd_s + + aswdifdS + ", aswdifu_s=" - + aswdifu_s + + aswdifuS + ", aswdirs_s=" - + aswdirs_s + + aswdirS + ", sobs_rad=" - + sobs_rad + + sobsRad + ", t_131m=" - + t_131m + + t131m + ", t_2m=" - + t_2m + + t2m + ", t_g=" - + t_g + + tG + ", u_10m=" - + u_10m + + u10m + ", v_10m=" - + v_10m + + v10m + ", z0=" + z0 + ", p_20m=" - + p_20m + + p20m + ", p_65m=" - + p_65m + + p65m + ", p_131m=" - + p_131m + + p131m + ", u_20m=" - + u_20m + + u20m + ", v_20m=" - + v_20m + + v20m + ", w_20m=" - + w_20m + + w20m + ", u_65m=" - + u_65m + + u65m + ", v_65m=" - + v_65m + + v65m + ", w_65m=" - + w_65m + + w65m + ", u_131m=" - + u_131m + + u131m + ", v_131m=" - + v_131m + + v131m + ", w_131m=" - + w_131m + + w131m + ", u_216m=" - + u_216m + + u216m + ", v_216m=" - + v_216m + + v216m + ", w_216m=" - + w_216m + + w216m + '}'; } diff --git a/src/main/java/edu/ie3/tools/utils/FileEraser.java b/src/main/java/edu/ie3/tools/utils/FileEraser.java index bb69dcd..dd1484f 100644 --- a/src/main/java/edu/ie3/tools/utils/FileEraser.java +++ b/src/main/java/edu/ie3/tools/utils/FileEraser.java @@ -44,11 +44,11 @@ private void erase(@NotNull FileModel file) { // delete archive file if (file.isDecompressed()) { String filename = file.getBZ2FileName(); - file.setArchivefile_deleted(eraseFile(fullDirectoryPath + filename)); + file.setArchiveFileDeleted(eraseFile(fullDirectoryPath + filename)); filestatusLogger.trace( file.getName() + " | ad" - + (file.isArchivefile_deleted() + + (file.isArchiveFileDeleted() ? "t | archivefile_deleted = true" : "f | archivefile_deleted = false") + "| FileEraser"); @@ -56,14 +56,14 @@ private void erase(@NotNull FileModel file) { // delete grib file if (file.isPersisted() - || (file.isValid_file() != null && !file.isValid_file()) - || !file.isSufficient_size()) { + || (file.isValidFile() != null && !file.isValidFile()) + || !file.isSufficientSize()) { String filename = file.getGRIB2FileName(); - file.setGribfile_deleted(eraseFile(fullDirectoryPath + filename)); + file.setGribFileDeleted(eraseFile(fullDirectoryPath + filename)); filestatusLogger.trace( file.getName() + " | gd" - + (file.isGribfile_deleted() + + (file.isGribFileDeleted() ? "t | gribfile_deleted = true" : "f | gribfile_deleted = false") + "| FileEraser"); diff --git a/src/test/java/edu/ie3/tools/models/persistence/ICONWeatherModelTest.java b/src/test/java/edu/ie3/tools/models/persistence/ICONWeatherModelTest.java index 497007d..4af85e5 100644 --- a/src/test/java/edu/ie3/tools/models/persistence/ICONWeatherModelTest.java +++ b/src/test/java/edu/ie3/tools/models/persistence/ICONWeatherModelTest.java @@ -65,7 +65,7 @@ public void getInterpolatedEntity() { ICONWeatherModel newWeather = new ICONWeatherModel(date, coordinate); interpolatedEntity.setDate(date); interpolatedEntity.setCoordinate(coordinate); - newWeather.setAlb_rad(alb_rad); + newWeather.setAlbRad(alb_rad); interpolatedEntity = ICONWeatherModel.getInterpolatedEntity(weather, newWeather); interpolatedEntity.setDate(date); @@ -85,32 +85,32 @@ public void getInterpolatedEntity() { interpolatedEntity.setDate(date); interpolatedEntity.setCoordinate(coordinate); - assertEquals(collectedParameterValues.get("alb_rad") / 10, interpolatedEntity.getAlb_rad()); - assertEquals(collectedParameterValues.get("asob_s") / 10, interpolatedEntity.getAsob_s()); - assertEquals(collectedParameterValues.get("aswdifd_s") / 10, interpolatedEntity.getAswdifd_s()); - assertEquals(collectedParameterValues.get("aswdifu_s") / 10, interpolatedEntity.getAswdifu_s()); - assertEquals(collectedParameterValues.get("aswdirs_s") / 10, interpolatedEntity.getAswdirs_s()); - assertEquals(collectedParameterValues.get("sobs_rad") / 10, interpolatedEntity.getSobs_rad()); - assertEquals(collectedParameterValues.get("p_20m") / 10, interpolatedEntity.getP_20m()); - assertEquals(collectedParameterValues.get("p_65m") / 10, interpolatedEntity.getP_65m()); - assertEquals(collectedParameterValues.get("p_131m") / 10, interpolatedEntity.getP_131m()); - assertEquals(collectedParameterValues.get("t_131m") / 10, interpolatedEntity.getT_131m()); - assertEquals(collectedParameterValues.get("t_2m") / 10, interpolatedEntity.getT_2m()); - assertEquals(collectedParameterValues.get("t_g") / 10, interpolatedEntity.getT_g()); - assertEquals(collectedParameterValues.get("u_10m") / 10, interpolatedEntity.getU_10m()); - assertEquals(collectedParameterValues.get("u_131m") / 10, interpolatedEntity.getU_131m()); - assertEquals(collectedParameterValues.get("u_20m") / 10, interpolatedEntity.getU_20m()); - assertEquals(collectedParameterValues.get("u_216m") / 10, interpolatedEntity.getU_216m()); - assertEquals(collectedParameterValues.get("u_65m") / 10, interpolatedEntity.getU_65m()); - assertEquals(collectedParameterValues.get("v_10m") / 10, interpolatedEntity.getV_10m()); - assertEquals(collectedParameterValues.get("v_131m") / 10, interpolatedEntity.getV_131m()); - assertEquals(collectedParameterValues.get("v_20m") / 10, interpolatedEntity.getV_20m()); - assertEquals(collectedParameterValues.get("v_216m") / 10, interpolatedEntity.getV_216m()); - assertEquals(collectedParameterValues.get("v_65m") / 10, interpolatedEntity.getV_65m()); - assertEquals(collectedParameterValues.get("w_131m") / 10, interpolatedEntity.getW_131m()); - assertEquals(collectedParameterValues.get("w_20m") / 10, interpolatedEntity.getW_20m()); - assertEquals(collectedParameterValues.get("w_216m") / 10, interpolatedEntity.getW_216m()); - assertEquals(collectedParameterValues.get("w_65m") / 10, interpolatedEntity.getW_65m()); + assertEquals(collectedParameterValues.get("alb_rad") / 10, interpolatedEntity.getAlbRad()); + assertEquals(collectedParameterValues.get("asob_s") / 10, interpolatedEntity.getAsobS()); + assertEquals(collectedParameterValues.get("aswdifd_s") / 10, interpolatedEntity.getAswdifdS()); + assertEquals(collectedParameterValues.get("aswdifu_s") / 10, interpolatedEntity.getAswdifuS()); + assertEquals(collectedParameterValues.get("aswdirs_s") / 10, interpolatedEntity.getAswdirS()); + assertEquals(collectedParameterValues.get("sobs_rad") / 10, interpolatedEntity.getSobsRad()); + assertEquals(collectedParameterValues.get("p_20m") / 10, interpolatedEntity.getP20m()); + assertEquals(collectedParameterValues.get("p_65m") / 10, interpolatedEntity.getP65m()); + assertEquals(collectedParameterValues.get("p_131m") / 10, interpolatedEntity.getP131m()); + assertEquals(collectedParameterValues.get("t_131m") / 10, interpolatedEntity.getT131m()); + assertEquals(collectedParameterValues.get("t_2m") / 10, interpolatedEntity.getT2m()); + assertEquals(collectedParameterValues.get("t_g") / 10, interpolatedEntity.getTG()); + assertEquals(collectedParameterValues.get("u_10m") / 10, interpolatedEntity.getU10m()); + assertEquals(collectedParameterValues.get("u_131m") / 10, interpolatedEntity.getU131m()); + assertEquals(collectedParameterValues.get("u_20m") / 10, interpolatedEntity.getU20m()); + assertEquals(collectedParameterValues.get("u_216m") / 10, interpolatedEntity.getU216m()); + assertEquals(collectedParameterValues.get("u_65m") / 10, interpolatedEntity.getU65m()); + assertEquals(collectedParameterValues.get("v_10m") / 10, interpolatedEntity.getV10m()); + assertEquals(collectedParameterValues.get("v_131m") / 10, interpolatedEntity.getV131m()); + assertEquals(collectedParameterValues.get("v_20m") / 10, interpolatedEntity.getV20m()); + assertEquals(collectedParameterValues.get("v_216m") / 10, interpolatedEntity.getV216m()); + assertEquals(collectedParameterValues.get("v_65m") / 10, interpolatedEntity.getV65m()); + assertEquals(collectedParameterValues.get("w_131m") / 10, interpolatedEntity.getW131m()); + assertEquals(collectedParameterValues.get("w_20m") / 10, interpolatedEntity.getW20m()); + assertEquals(collectedParameterValues.get("w_216m") / 10, interpolatedEntity.getW216m()); + assertEquals(collectedParameterValues.get("w_65m") / 10, interpolatedEntity.getW65m()); assertEquals(collectedParameterValues.get("z0") / 10, interpolatedEntity.getZ0()); } @@ -153,15 +153,15 @@ public void getSQLUpsertStatement() { @Test public void setParameter() { weather.setParameter(Parameter.ASOB_S, 1.337); - assertEquals(1.337, weather.getAsob_s()); // value changed + assertEquals(1.337, weather.getAsobS()); // value changed weather.setParameter(Parameter.ASOB_S, null); - assertEquals(1.337, weather.getAsob_s()); // value does not change, when null + assertEquals(1.337, weather.getAsobS()); // value does not change, when null weather.setParameter(Parameter.ASOB_S, asob_s); assertEquals(generateWeatherEntity(), weather); // no other values should have changed weather.setParameter(Parameter.U_10M, 4.2); - assertEquals(4.2, weather.getU_10m()); // value changed for single level values + assertEquals(4.2, weather.getU10m()); // value changed for single level values weather.setParameter(Parameter.U_216M, 2.4); - assertEquals(2.4, weather.getU_216m()); // value changed for multi level values + assertEquals(2.4, weather.getU216m()); // value changed for multi level values } @Test @@ -180,9 +180,9 @@ public void interpolateParameter() { assertEquals( weather, defaultWeather); // don't (really) interpolate when interpolationRatio is 0 weather.interpolateParameter(Parameter.ALBEDO, 1.0, 1.337); - assertEquals(1.337, weather.getAlb_rad()); // overwrite when interpolationRatio is 1 + assertEquals(1.337, weather.getAlbRad()); // overwrite when interpolationRatio is 1 weather.interpolateParameter(Parameter.ASOB_S, 0.5, 1.337); - assertEquals((asob_s + 1.337) / 2, weather.getAsob_s()); // 50 % old value, 50% new value + assertEquals((asob_s + 1.337) / 2, weather.getAsobS()); // 50 % old value, 50% new value weather.interpolateParameter(Parameter.Z0, 0.67, 100.0); assertEquals(z0 * (1 - 0.67) + 100 * 0.67, weather.getZ0()); // 33% old value, 66% new value } @@ -192,32 +192,32 @@ public void interpolateValues() { ICONWeatherModel randWeather = generateRandomWeatherEntity(); HashMap collectedParameterValues = collectParameterValues(weather, randWeather); weather.interpolateValues(randWeather, 0.5); - assertEquals(collectedParameterValues.get("alb_rad") / 2, weather.getAlb_rad()); - assertEquals(collectedParameterValues.get("asob_s") / 2, weather.getAsob_s()); - assertEquals(collectedParameterValues.get("aswdifd_s") / 2, weather.getAswdifd_s()); - assertEquals(collectedParameterValues.get("aswdifu_s") / 2, weather.getAswdifu_s()); - assertEquals(collectedParameterValues.get("aswdirs_s") / 2, weather.getAswdirs_s()); - assertEquals(collectedParameterValues.get("sobs_rad") / 2, weather.getSobs_rad()); - assertEquals(collectedParameterValues.get("p_20m") / 2, weather.getP_20m()); - assertEquals(collectedParameterValues.get("p_65m") / 2, weather.getP_65m()); - assertEquals(collectedParameterValues.get("p_131m") / 2, weather.getP_131m()); - assertEquals(collectedParameterValues.get("t_131m") / 2, weather.getT_131m()); - assertEquals(collectedParameterValues.get("t_2m") / 2, weather.getT_2m()); - assertEquals(collectedParameterValues.get("t_g") / 2, weather.getT_g()); - assertEquals(collectedParameterValues.get("u_10m") / 2, weather.getU_10m()); - assertEquals(collectedParameterValues.get("u_131m") / 2, weather.getU_131m()); - assertEquals(collectedParameterValues.get("u_20m") / 2, weather.getU_20m()); - assertEquals(collectedParameterValues.get("u_216m") / 2, weather.getU_216m()); - assertEquals(collectedParameterValues.get("u_65m") / 2, weather.getU_65m()); - assertEquals(collectedParameterValues.get("v_10m") / 2, weather.getV_10m()); - assertEquals(collectedParameterValues.get("v_131m") / 2, weather.getV_131m()); - assertEquals(collectedParameterValues.get("v_20m") / 2, weather.getV_20m()); - assertEquals(collectedParameterValues.get("v_216m") / 2, weather.getV_216m()); - assertEquals(collectedParameterValues.get("v_65m") / 2, weather.getV_65m()); - assertEquals(collectedParameterValues.get("w_131m") / 2, weather.getW_131m()); - assertEquals(collectedParameterValues.get("w_20m") / 2, weather.getW_20m()); - assertEquals(collectedParameterValues.get("w_216m") / 2, weather.getW_216m()); - assertEquals(collectedParameterValues.get("w_65m") / 2, weather.getW_65m()); + assertEquals(collectedParameterValues.get("alb_rad") / 2, weather.getAlbRad()); + assertEquals(collectedParameterValues.get("asob_s") / 2, weather.getAsobS()); + assertEquals(collectedParameterValues.get("aswdifd_s") / 2, weather.getAswdifdS()); + assertEquals(collectedParameterValues.get("aswdifu_s") / 2, weather.getAswdifuS()); + assertEquals(collectedParameterValues.get("aswdirs_s") / 2, weather.getAswdirS()); + assertEquals(collectedParameterValues.get("sobs_rad") / 2, weather.getSobsRad()); + assertEquals(collectedParameterValues.get("p_20m") / 2, weather.getP20m()); + assertEquals(collectedParameterValues.get("p_65m") / 2, weather.getP65m()); + assertEquals(collectedParameterValues.get("p_131m") / 2, weather.getP131m()); + assertEquals(collectedParameterValues.get("t_131m") / 2, weather.getT131m()); + assertEquals(collectedParameterValues.get("t_2m") / 2, weather.getT2m()); + assertEquals(collectedParameterValues.get("t_g") / 2, weather.getTG()); + assertEquals(collectedParameterValues.get("u_10m") / 2, weather.getU10m()); + assertEquals(collectedParameterValues.get("u_131m") / 2, weather.getU131m()); + assertEquals(collectedParameterValues.get("u_20m") / 2, weather.getU20m()); + assertEquals(collectedParameterValues.get("u_216m") / 2, weather.getU216m()); + assertEquals(collectedParameterValues.get("u_65m") / 2, weather.getU65m()); + assertEquals(collectedParameterValues.get("v_10m") / 2, weather.getV10m()); + assertEquals(collectedParameterValues.get("v_131m") / 2, weather.getV131m()); + assertEquals(collectedParameterValues.get("v_20m") / 2, weather.getV20m()); + assertEquals(collectedParameterValues.get("v_216m") / 2, weather.getV216m()); + assertEquals(collectedParameterValues.get("v_65m") / 2, weather.getV65m()); + assertEquals(collectedParameterValues.get("w_131m") / 2, weather.getW131m()); + assertEquals(collectedParameterValues.get("w_20m") / 2, weather.getW20m()); + assertEquals(collectedParameterValues.get("w_216m") / 2, weather.getW216m()); + assertEquals(collectedParameterValues.get("w_65m") / 2, weather.getW65m()); assertEquals(collectedParameterValues.get("z0") / 2, weather.getZ0()); } @@ -267,32 +267,32 @@ private static ICONWeatherModel generateRandomWeatherEntity() { ICONWeatherModel randEntity = new ICONWeatherModel(); double min = -200d; double max = 200d; - randEntity.setAlb_rad((Math.random() * ((max - min) + 1) + min)); - randEntity.setAsob_s((Math.random() * ((max - min) + 1) + min)); - randEntity.setAswdifd_s((Math.random() * ((max - min) + 1) + min)); - randEntity.setAswdifu_s((Math.random() * ((max - min) + 1) + min)); - randEntity.setAswdirs_s((Math.random() * ((max - min) + 1) + min)); - randEntity.setSobs_rad((Math.random() * ((max - min) + 1) + min)); - randEntity.setP_20m((Math.random() * ((max - min) + 1) + min)); - randEntity.setP_65m((Math.random() * ((max - min) + 1) + min)); - randEntity.setP_131m((Math.random() * ((max - min) + 1) + min)); - randEntity.setT_131m((Math.random() * ((max - min) + 1) + min)); - randEntity.setT_2m((Math.random() * ((max - min) + 1) + min)); - randEntity.setT_g((Math.random() * ((max - min) + 1) + min)); - randEntity.setU_10m((Math.random() * ((max - min) + 1) + min)); - randEntity.setU_131m((Math.random() * ((max - min) + 1) + min)); - randEntity.setU_20m((Math.random() * ((max - min) + 1) + min)); - randEntity.setU_216m((Math.random() * ((max - min) + 1) + min)); - randEntity.setU_65m((Math.random() * ((max - min) + 1) + min)); - randEntity.setV_10m((Math.random() * ((max - min) + 1) + min)); - randEntity.setV_131m((Math.random() * ((max - min) + 1) + min)); - randEntity.setV_20m((Math.random() * ((max - min) + 1) + min)); - randEntity.setV_216m((Math.random() * ((max - min) + 1) + min)); - randEntity.setV_65m((Math.random() * ((max - min) + 1) + min)); - randEntity.setW_131m((Math.random() * ((max - min) + 1) + min)); - randEntity.setW_20m((Math.random() * ((max - min) + 1) + min)); - randEntity.setW_216m((Math.random() * ((max - min) + 1) + min)); - randEntity.setW_65m((Math.random() * ((max - min) + 1) + min)); + randEntity.setAlbRad((Math.random() * ((max - min) + 1) + min)); + randEntity.setAsobS((Math.random() * ((max - min) + 1) + min)); + randEntity.setAswdifdS((Math.random() * ((max - min) + 1) + min)); + randEntity.setAswdifuS((Math.random() * ((max - min) + 1) + min)); + randEntity.setAswdirS((Math.random() * ((max - min) + 1) + min)); + randEntity.setSobsRad((Math.random() * ((max - min) + 1) + min)); + randEntity.setP20m((Math.random() * ((max - min) + 1) + min)); + randEntity.setP65m((Math.random() * ((max - min) + 1) + min)); + randEntity.setP131m((Math.random() * ((max - min) + 1) + min)); + randEntity.setT131m((Math.random() * ((max - min) + 1) + min)); + randEntity.setT2m((Math.random() * ((max - min) + 1) + min)); + randEntity.setTG((Math.random() * ((max - min) + 1) + min)); + randEntity.setU10m((Math.random() * ((max - min) + 1) + min)); + randEntity.setU131m((Math.random() * ((max - min) + 1) + min)); + randEntity.setU20m((Math.random() * ((max - min) + 1) + min)); + randEntity.setU216m((Math.random() * ((max - min) + 1) + min)); + randEntity.setU65m((Math.random() * ((max - min) + 1) + min)); + randEntity.setV10m((Math.random() * ((max - min) + 1) + min)); + randEntity.setV131m((Math.random() * ((max - min) + 1) + min)); + randEntity.setV20m((Math.random() * ((max - min) + 1) + min)); + randEntity.setV216m((Math.random() * ((max - min) + 1) + min)); + randEntity.setV65m((Math.random() * ((max - min) + 1) + min)); + randEntity.setW131m((Math.random() * ((max - min) + 1) + min)); + randEntity.setW20m((Math.random() * ((max - min) + 1) + min)); + randEntity.setW216m((Math.random() * ((max - min) + 1) + min)); + randEntity.setW65m((Math.random() * ((max - min) + 1) + min)); randEntity.setZ0((Math.random() * ((max - min) + 1) + min)); return randEntity; } @@ -327,32 +327,32 @@ private static HashMap collectParameterValues(ICONWeatherModel.. map.put("w_65m", 0.0); map.put("z0", 0.0); for (ICONWeatherModel entity : entities) { - map.put("alb_rad", map.get("alb_rad") + entity.getAlb_rad()); - map.put("asob_s", map.get("asob_s") + entity.getAsob_s()); - map.put("aswdifd_s", map.get("aswdifd_s") + entity.getAswdifd_s()); - map.put("aswdifu_s", map.get("aswdifu_s") + entity.getAswdifu_s()); - map.put("aswdirs_s", map.get("aswdirs_s") + entity.getAswdirs_s()); - map.put("sobs_rad", map.get("sobs_rad") + entity.getSobs_rad()); - map.put("p_20m", map.get("p_20m") + entity.getP_20m()); - map.put("p_65m", map.get("p_65m") + entity.getP_65m()); - map.put("p_131m", map.get("p_131m") + entity.getP_131m()); - map.put("t_131m", map.get("t_131m") + entity.getT_131m()); - map.put("t_2m", map.get("t_2m") + entity.getT_2m()); - map.put("t_g", map.get("t_g") + entity.getT_g()); - map.put("u_10m", map.get("u_10m") + entity.getU_10m()); - map.put("u_131m", map.get("u_131m") + entity.getU_131m()); - map.put("u_20m", map.get("u_20m") + entity.getU_20m()); - map.put("u_216m", map.get("u_216m") + entity.getU_216m()); - map.put("u_65m", map.get("u_65m") + entity.getU_65m()); - map.put("v_10m", map.get("v_10m") + entity.getV_10m()); - map.put("v_131m", map.get("v_131m") + entity.getV_131m()); - map.put("v_20m", map.get("v_20m") + entity.getV_20m()); - map.put("v_216m", map.get("v_216m") + entity.getV_216m()); - map.put("v_65m", map.get("v_65m") + entity.getV_65m()); - map.put("w_131m", map.get("w_131m") + entity.getW_131m()); - map.put("w_20m", map.get("w_20m") + entity.getW_20m()); - map.put("w_216m", map.get("w_216m") + entity.getW_216m()); - map.put("w_65m", map.get("w_65m") + entity.getW_65m()); + map.put("alb_rad", map.get("alb_rad") + entity.getAlbRad()); + map.put("asob_s", map.get("asob_s") + entity.getAsobS()); + map.put("aswdifd_s", map.get("aswdifd_s") + entity.getAswdifdS()); + map.put("aswdifu_s", map.get("aswdifu_s") + entity.getAswdifuS()); + map.put("aswdirs_s", map.get("aswdirs_s") + entity.getAswdirS()); + map.put("sobs_rad", map.get("sobs_rad") + entity.getSobsRad()); + map.put("p_20m", map.get("p_20m") + entity.getP20m()); + map.put("p_65m", map.get("p_65m") + entity.getP65m()); + map.put("p_131m", map.get("p_131m") + entity.getP131m()); + map.put("t_131m", map.get("t_131m") + entity.getT131m()); + map.put("t_2m", map.get("t_2m") + entity.getT2m()); + map.put("t_g", map.get("t_g") + entity.getTG()); + map.put("u_10m", map.get("u_10m") + entity.getU10m()); + map.put("u_131m", map.get("u_131m") + entity.getU131m()); + map.put("u_20m", map.get("u_20m") + entity.getU20m()); + map.put("u_216m", map.get("u_216m") + entity.getU216m()); + map.put("u_65m", map.get("u_65m") + entity.getU65m()); + map.put("v_10m", map.get("v_10m") + entity.getV10m()); + map.put("v_131m", map.get("v_131m") + entity.getV131m()); + map.put("v_20m", map.get("v_20m") + entity.getV20m()); + map.put("v_216m", map.get("v_216m") + entity.getV216m()); + map.put("v_65m", map.get("v_65m") + entity.getV65m()); + map.put("w_131m", map.get("w_131m") + entity.getW131m()); + map.put("w_20m", map.get("w_20m") + entity.getW20m()); + map.put("w_216m", map.get("w_216m") + entity.getW216m()); + map.put("w_65m", map.get("w_65m") + entity.getW65m()); map.put("z0", map.get("z0") + entity.getZ0()); } return map; @@ -422,32 +422,32 @@ public ICONWeatherModel generateWeatherEntity( ZonedDateTime date, CoordinateModel coordinate) { ICONWeatherModel newWeather = new ICONWeatherModel(date, coordinate); - newWeather.setAlb_rad(alb_rad); - newWeather.setAsob_s(asob_s); - newWeather.setAswdifd_s(aswdifd_s); - newWeather.setAswdifu_s(aswdifu_s); - newWeather.setAswdirs_s(aswdirs_s); - newWeather.setSobs_rad(sobs_rad); - newWeather.setP_20m(p_20m); - newWeather.setP_65m(p_65m); - newWeather.setP_131m(p_131m); - newWeather.setT_131m(t_131m); - newWeather.setT_2m(t_2m); - newWeather.setT_g(t_g); - newWeather.setU_10m(u_10m); - newWeather.setU_131m(u_131m); - newWeather.setU_20m(u_20m); - newWeather.setU_216m(u_216m); - newWeather.setU_65m(u_65m); - newWeather.setV_10m(v_10m); - newWeather.setV_131m(v_131m); - newWeather.setV_20m(v_20m); - newWeather.setV_216m(v_216m); - newWeather.setV_65m(v_65m); - newWeather.setW_131m(w_131m); - newWeather.setW_20m(w_20m); - newWeather.setW_216m(w_216m); - newWeather.setW_65m(w_65m); + newWeather.setAlbRad(alb_rad); + newWeather.setAsobS(asob_s); + newWeather.setAswdifdS(aswdifd_s); + newWeather.setAswdifuS(aswdifu_s); + newWeather.setAswdirS(aswdirs_s); + newWeather.setSobsRad(sobs_rad); + newWeather.setP20m(p_20m); + newWeather.setP65m(p_65m); + newWeather.setP131m(p_131m); + newWeather.setT131m(t_131m); + newWeather.setT2m(t_2m); + newWeather.setTG(t_g); + newWeather.setU10m(u_10m); + newWeather.setU131m(u_131m); + newWeather.setU20m(u_20m); + newWeather.setU216m(u_216m); + newWeather.setU65m(u_65m); + newWeather.setV10m(v_10m); + newWeather.setV131m(v_131m); + newWeather.setV20m(v_20m); + newWeather.setV216m(v_216m); + newWeather.setV65m(v_65m); + newWeather.setW131m(w_131m); + newWeather.setW20m(w_20m); + newWeather.setW216m(w_216m); + newWeather.setW65m(w_65m); newWeather.setZ0(z0); return newWeather; }