Skip to content

Comments

119 meteo imgw missing headers#120

Merged
bczernecki merged 9 commits intomasterfrom
119-meteo_imgw-missing-headers
Feb 3, 2026
Merged

119 meteo imgw missing headers#120
bczernecki merged 9 commits intomasterfrom
119-meteo_imgw-missing-headers

Conversation

@bczernecki
Copy link
Owner

No description provided.

@bczernecki bczernecki self-assigned this Feb 3, 2026
@bczernecki bczernecki added the bug Something isn't working label Feb 3, 2026
@bczernecki bczernecki linked an issue Feb 3, 2026 that may be closed by this pull request
@bczernecki bczernecki requested a review from Copilot February 3, 2026 01:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses corrupted header files in the meteo_imgw_* family of functions due to changes in the IMGW-PIB data repository. The PR implements a new, simplified approach to parsing metadata files and updates column names throughout the codebase to use abbreviated codes (NSP, ROK, MC, DZ, POST, etc.) instead of Polish descriptive names.

Changes:

  • Simplified metadata parsing logic in clean_metadata_meteo() using regex pattern matching instead of complex string manipulation
  • Updated column naming scheme from Polish descriptive names ("Kod stacji", "Nazwa stacji", "Rok") to abbreviated codes (NSP, POST, ROK, MC, DZ, GG)
  • Removed or modified status column filtering logic across all meteo_imgw functions
  • Standardized use of data.table operations for improved performance

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
R/clean_metadata_meteo.R Complete rewrite of metadata parsing logic using simplified regex-based approach; returns 2 columns instead of 3
R/meteo_imgw_daily.R Updated to use new abbreviated column names; added label attributes; modified status filtering; improved data.table usage
R/meteo_imgw_hourly.R Updated to use new abbreviated column names; removed status filtering; standardized data.table operations
R/meteo_imgw_monthly.R Updated to use new abbreviated column names; removed status filtering; added NA column name handling
R/meteo_metadata_imgw.R Added blank line (whitespace-only change)
NEWS.md Documented fix for corrupted header files in version 1.2.9
DESCRIPTION Updated version to 1.2.9.9001 (development version)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 84.47205% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.76%. Comparing base (0277243) to head (5456cd8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
R/meteo_imgw_monthly.R 68.75% 20 Missing ⚠️
R/utils.R 72.72% 3 Missing ⚠️
R/meteo_imgw_daily.R 98.11% 1 Missing ⚠️
R/nearest_stations_imgw.R 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
- Coverage   92.83%   90.76%   -2.08%     
==========================================
  Files          33       33              
  Lines        1885     1841      -44     
==========================================
- Hits         1750     1671      -79     
- Misses        135      170      +35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 12 comments.

Comments suppressed due to low confidence (2)

R/meteo_imgw_daily.R:334

  • Potential undefined variable. If the tryCatch at line 295 returns NULL (when d is NULL), neither the condition at line 315 (is.data.frame(d)) nor the condition at line 323 (!is.null(d) & !is.data.frame(d)) will be TRUE, leaving data1 undefined. This will cause an error when data1 is referenced at line 334. Consider adding an else clause or a check to handle the case where d is NULL.
        if (is.data.frame(d)) {
          data1 = d
          colnames(data1) = meta[[1]]$parameters
          if (status == FALSE) {
            data1[grep("^W", colnames(data1))] = NULL
          }
        }

        if (!is.null(d) & !is.data.frame(d)) {
          invisible(unzip(zipfile = temp, exdir = temp2))
          file1 = paste(temp2, dir(temp2), sep = "/")[1]
          data1 = imgw_read(translit, file1)
          colnames(data1) = meta[[1]]$parameters
          # remove status
          if (status == FALSE) {
            data1[grep("^W", colnames(data1))] = NULL
          }
        } # end of corrupted zips
        unlink(c(temp, temp2))
        all_data[[length(all_data) + 1]] = data1

R/meteo_imgw_daily.R:270

  • Potential undefined variable. If the tryCatch at line 210 returns NULL (when d is NULL), neither the condition at line 232 (is.data.frame(d)) nor the condition at line 240 (!is.null(d) & !is.data.frame(d)) will be TRUE, leaving data1 undefined. This will cause errors when data1 is referenced at lines 255, 263, or 269. Consider adding an else clause or a check to handle the case where d is NULL.
        if (is.data.frame(d)) {
          data1 = d
          colnames(data1) = meta[[1]]$parameters
          if (status == FALSE) {
            data1[grep("^W", colnames(data1))] = NULL
          }
        }

        if (!is.null(d) & !is.data.frame(d)) {
          invisible(unzip(zipfile = temp, exdir = temp2))
          file1 = paste(temp2, dir(temp2), sep = "/")[1]
          data1 = imgw_read(translit, file1)
          colnames(data1) = meta[[1]]$parameters

          file2 = paste(temp2, dir(temp2), sep = "/")[2]
          if (file.exists(file2)) {
            data2 = imgw_read(translit, file2)
            colnames(data2) = meta[[2]]$parameters
          }
        }

        # remove statuses
        if (status == FALSE) {
          data1[grep("^W", colnames(data1))] = NULL
          if (file.exists(file2)) {
            data2[grep("^W", colnames(data2))] = NULL
          }
        }

        unlink(c(temp, temp2))
        if (file.exists(file2)) {
          all_data[[length(all_data) + 1]] = merge(data1,
            data2,
            by = c("NSP", "ROK", "MC", "DZ"),
            all.x = TRUE
          )
        } else {
          all_data[[length(all_data) + 1]] = data1
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bczernecki bczernecki merged commit 50c3684 into master Feb 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

meteo_imgw not working - corrupted headers

1 participant