|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 |
|
3 | | -__author__ = "Giovani Hidalgo Ceotto, Guilherme Fernandes Alves, Lucas Azevedo Pezente" |
| 3 | +__author__ = "Giovani Hidalgo Ceotto, Guilherme Fernandes Alves, Lucas Azevedo Pezente, Oscar Mauricio Prada Ramirez, Lucas Kierulff Balabram" |
4 | 4 | __copyright__ = "Copyright 20XX, Projeto Jupiter" |
5 | 5 | __license__ = "MIT" |
6 | 6 |
|
@@ -1713,7 +1713,7 @@ def processForecastReanalysis(self, file, dictionary): |
1713 | 1713 | file : string |
1714 | 1714 | String containing path to local netCDF file or URL of an |
1715 | 1715 | OPeNDAP file, such as NOAA's NOMAD or UCAR TRHEDDS server. |
1716 | | - dicitonary : dictionary |
| 1716 | + dictionary : dictionary |
1717 | 1717 | Specifies the dictionary to be used when reading netCDF and |
1718 | 1718 | OPeNDAP files, allowing for the correct retrieval of data. |
1719 | 1719 | The dictionary structure should specify the short names |
@@ -1762,11 +1762,17 @@ def processForecastReanalysis(self, file, dictionary): |
1762 | 1762 | latArray = weatherData.variables[dictionary["latitude"]][:].tolist() |
1763 | 1763 |
|
1764 | 1764 | # Find time index |
1765 | | - timeIndex = netCDF4.date2index(self.date, timeArray, select="nearest") |
| 1765 | + timeIndex = netCDF4.date2index( |
| 1766 | + self.date, timeArray, calendar="gregorian", select="nearest" |
| 1767 | + ) |
1766 | 1768 | # Convert times do dates and numbers |
1767 | | - inputTimeNum = netCDF4.date2num(self.date, timeArray.units, calendar="standard") |
| 1769 | + inputTimeNum = netCDF4.date2num( |
| 1770 | + self.date, timeArray.units, calendar="gregorian" |
| 1771 | + ) |
1768 | 1772 | fileTimeNum = timeArray[timeIndex] |
1769 | | - fileTimeDate = netCDF4.num2date(timeArray[timeIndex], timeArray.units) |
| 1773 | + fileTimeDate = netCDF4.num2date( |
| 1774 | + timeArray[timeIndex], timeArray.units, calendar="gregorian" |
| 1775 | + ) |
1770 | 1776 | # Check if time is inside range supplied by file |
1771 | 1777 | if timeIndex == 0 and inputTimeNum < fileTimeNum: |
1772 | 1778 | raise ValueError( |
@@ -2039,10 +2045,16 @@ def processForecastReanalysis(self, file, dictionary): |
2039 | 2045 | ) |
2040 | 2046 |
|
2041 | 2047 | # Compute info data |
2042 | | - self.atmosphericModelInitDate = netCDF4.num2date(timeArray[0], timeArray.units) |
2043 | | - self.atmosphericModelEndDate = netCDF4.num2date(timeArray[-1], timeArray.units) |
| 2048 | + self.atmosphericModelInitDate = netCDF4.num2date( |
| 2049 | + timeArray[0], timeArray.units, calendar="gregorian" |
| 2050 | + ) |
| 2051 | + self.atmosphericModelEndDate = netCDF4.num2date( |
| 2052 | + timeArray[-1], timeArray.units, calendar="gregorian" |
| 2053 | + ) |
2044 | 2054 | self.atmosphericModelInterval = netCDF4.num2date( |
2045 | | - (timeArray[-1] - timeArray[0]) / (len(timeArray) - 1), timeArray.units |
| 2055 | + (timeArray[-1] - timeArray[0]) / (len(timeArray) - 1), |
| 2056 | + timeArray.units, |
| 2057 | + calendar="gregorian", |
2046 | 2058 | ).hour |
2047 | 2059 | self.atmosphericModelInitLat = latArray[0] |
2048 | 2060 | self.atmosphericModelEndLat = latArray[-1] |
@@ -2145,11 +2157,17 @@ def processEnsemble(self, file, dictionary): |
2145 | 2157 | latArray = weatherData.variables[dictionary["latitude"]][:].tolist() |
2146 | 2158 |
|
2147 | 2159 | # Find time index |
2148 | | - timeIndex = netCDF4.date2index(self.date, timeArray, select="nearest") |
| 2160 | + timeIndex = netCDF4.date2index( |
| 2161 | + self.date, timeArray, calendar="gregorian", select="nearest" |
| 2162 | + ) |
2149 | 2163 | # Convert times do dates and numbers |
2150 | | - inputTimeNum = netCDF4.date2num(self.date, timeArray.units) |
| 2164 | + inputTimeNum = netCDF4.date2num( |
| 2165 | + self.date, timeArray.units, calendar="gregorian" |
| 2166 | + ) |
2151 | 2167 | fileTimeNum = timeArray[timeIndex] |
2152 | | - fileTimeDate = netCDF4.num2date(timeArray[timeIndex], timeArray.units) |
| 2168 | + fileTimeDate = netCDF4.num2date( |
| 2169 | + timeArray[timeIndex], timeArray.units, calendar="gregorian" |
| 2170 | + ) |
2153 | 2171 | # Check if time is inside range supplied by file |
2154 | 2172 | if timeIndex == 0 and inputTimeNum < fileTimeNum: |
2155 | 2173 | raise ValueError( |
@@ -2390,10 +2408,16 @@ def processEnsemble(self, file, dictionary): |
2390 | 2408 | ) |
2391 | 2409 |
|
2392 | 2410 | # Compute info data |
2393 | | - self.atmosphericModelInitDate = netCDF4.num2date(timeArray[0], timeArray.units) |
2394 | | - self.atmosphericModelEndDate = netCDF4.num2date(timeArray[-1], timeArray.units) |
| 2411 | + self.atmosphericModelInitDate = netCDF4.num2date( |
| 2412 | + timeArray[0], timeArray.units, calendar="gregorian" |
| 2413 | + ) |
| 2414 | + self.atmosphericModelEndDate = netCDF4.num2date( |
| 2415 | + timeArray[-1], timeArray.units, calendar="gregorian" |
| 2416 | + ) |
2395 | 2417 | self.atmosphericModelInterval = netCDF4.num2date( |
2396 | | - (timeArray[-1] - timeArray[0]) / (len(timeArray) - 1), timeArray.units |
| 2418 | + (timeArray[-1] - timeArray[0]) / (len(timeArray) - 1), |
| 2419 | + timeArray.units, |
| 2420 | + calendar="gregorian", |
2397 | 2421 | ).hour |
2398 | 2422 | self.atmosphericModelInitLat = latArray[0] |
2399 | 2423 | self.atmosphericModelEndLat = latArray[-1] |
|
0 commit comments