pyVPRM 3.0__tar.gz → 5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {pyvprm-3.0/pyVPRM.egg-info → pyvprm-5.0}/PKG-INFO +2 -1
  2. {pyvprm-3.0 → pyvprm-5.0}/README.md +1 -1
  3. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/VPRM.py +8 -4
  4. pyvprm-5.0/pyVPRM/__init__.py +1 -0
  5. pyvprm-5.0/pyVPRM/lib/reproject_fiona.py +64 -0
  6. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/meteorologies/era5_monthly_xr.py +44 -4
  7. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_configs/copernicus_land_cover.yaml +32 -32
  8. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_configs/esa_world_cover.yaml +38 -22
  9. {pyvprm-3.0 → pyvprm-5.0/pyVPRM.egg-info}/PKG-INFO +2 -1
  10. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM.egg-info/SOURCES.txt +1 -0
  11. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM.egg-info/requires.txt +1 -0
  12. {pyvprm-3.0 → pyvprm-5.0}/setup.py +2 -1
  13. pyvprm-3.0/pyVPRM/__init__.py +0 -1
  14. {pyvprm-3.0 → pyvprm-5.0}/LICENSE +0 -0
  15. {pyvprm-3.0 → pyvprm-5.0}/MANIFEST.in +0 -0
  16. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/__init__.py +0 -0
  17. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/downmodis.py +0 -0
  18. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/fancy_plot.py +0 -0
  19. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/flux_tower_class.py +0 -0
  20. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/fluxnet_info/fluxnet_sites.pkl +0 -0
  21. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/fluxnet_info/site_infos.txt +0 -0
  22. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/lib/functions.py +0 -0
  23. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/meteorologies/__init__.py +0 -0
  24. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/meteorologies/era5_class_dkrz.py +0 -0
  25. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/meteorologies/era5_class_draft.py +0 -0
  26. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/meteorologies/met_base_class.py +0 -0
  27. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/meteorologies/met_local_measurement.py +0 -0
  28. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/__init__.py +0 -0
  29. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/base_manager.py +0 -0
  30. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/city.py +0 -0
  31. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/copernicus.py +0 -0
  32. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/esa_world_cover.py +0 -0
  33. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/mapbiomas.py +0 -0
  34. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/modis.py +0 -0
  35. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/proba_v.py +0 -0
  36. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/sentinel2.py +0 -0
  37. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/synmap.py +0 -0
  38. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/viirs.py +0 -0
  39. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/sat_managers/viirs09ga.py +0 -0
  40. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_configs/__init__.py +0 -0
  41. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_configs/synmap.yaml +0 -0
  42. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_models/__init__.py +0 -0
  43. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_models/model_params/__init__.py +0 -0
  44. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_models/vprm_base.py +0 -0
  45. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_models/vprm_base_no_xeric.py +0 -0
  46. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_models/vprm_modified.py +0 -0
  47. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM/vprm_models/vprm_nn.py +0 -0
  48. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM.egg-info/dependency_links.txt +0 -0
  49. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM.egg-info/not-zip-safe +0 -0
  50. {pyvprm-3.0 → pyvprm-5.0}/pyVPRM.egg-info/top_level.txt +0 -0
  51. {pyvprm-3.0 → pyvprm-5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyVPRM
3
- Version: 3.0
3
+ Version: 5.0
4
4
  Summary: Vegetation Photosynthesis and Respiration Model
5
5
  Home-page: https://github.com/tglauch/pyVPRM/
6
6
  Author: Theo Glauch
@@ -36,5 +36,6 @@ Requires-Dist: lxml
36
36
  Requires-Dist: requests
37
37
  Requires-Dist: statsmodels
38
38
  Requires-Dist: loguru
39
+ Requires-Dist: fiona
39
40
 
40
41
  A tool to calculate the CO2 exchange flux between atmosphere and terrestrial biosphere using the Vegetation Photosynthesis and Respiration Model
@@ -47,7 +47,7 @@ conda install esmpy
47
47
  Afterwards install ```pyVPRM``` using pip via
48
48
 
49
49
  ```
50
- pip install git+https://github.com/tglauch/pyVPRM.git
50
+ pip install pyVPRM
51
51
  ```
52
52
 
53
53
  ## Start your own project
@@ -38,7 +38,7 @@ regridder_options["conservative"] = "conserve"
38
38
 
39
39
  class vprm:
40
40
  """
41
- Class for the Vegetation Photosynthesis and Respiration Model
41
+ Main class for the Vegetation Photosynthesis and Respiration Model
42
42
  """
43
43
 
44
44
  def __init__(
@@ -617,9 +617,13 @@ class vprm:
617
617
  )
618
618
  src_grid.to_netcdf(src_temp_path)
619
619
  ds_out.to_netcdf(dest_temp_path)
620
- exec_str = "ESMF_RegridWeightGen --source {} --destination {} --weight {} -m conserve -r --netcdf4 –src_regional –dest_regional ".format(
621
- src_temp_path, dest_temp_path, regridder_save_path
622
- )
620
+ logger.debug(f"wrote source regridder: {src_temp_path}")
621
+ logger.debug(f"wrote dest regridder: {dest_temp_path}")
622
+ exec_str = (
623
+ "ESMF_RegridWeightGen --source {} --destination {} "
624
+ "--weight {} -m conserve -r --netcdf4 --src_regional"
625
+ " --dest_regional --ignore_unmapped"
626
+ ).format(src_temp_path, dest_temp_path, regridder_save_path)
623
627
  if mpi is True:
624
628
  exec_str = "mpirun -np {} ".format(n_cpus) + exec_str
625
629
  if not logs:
@@ -0,0 +1 @@
1
+ __version__ = "4.0"
@@ -0,0 +1,64 @@
1
+ """antimeridian-aware geopandas GeoDataFrame reprojection tool using fiona
2
+
3
+ This is an adaptation of this example from the geopandas documentation:
4
+ https://geopandas.org/en/stable/docs/user_guide/reproject_fiona.html#fiona-example
5
+
6
+ The main user-level function is transform_geodataframe(). Helper functions
7
+ crs_to_fiona() and base_transform() are not expected to be called by end-users.
8
+ """
9
+
10
+ from functools import partial
11
+
12
+ import fiona
13
+ import geopandas as gpd
14
+ from fiona.transform import transform_geom
15
+ from packaging import version
16
+ from pyproj import CRS
17
+ from pyproj.enums import WktVersion
18
+ from shapely.geometry import mapping, shape
19
+
20
+
21
+ # set up Fiona transformer
22
+ def crs_to_fiona(proj_crs):
23
+ """translate a CRS definition to a format fiona can understand
24
+
25
+ from https://geopandas.org/en/stable/docs/user_guide/reproject_fiona.html#fiona-example
26
+
27
+ helper function for transform_geodataframe()
28
+ """
29
+ proj_crs = CRS.from_user_input(proj_crs)
30
+ if version.parse(fiona.__gdal_version__) < version.parse("3.0.0"):
31
+ fio_crs = proj_crs.to_wkt(WktVersion.WKT1_GDAL)
32
+ else:
33
+ # GDAL 3+ can use WKT2
34
+ fio_crs = proj_crs.to_wkt()
35
+ return fio_crs
36
+
37
+
38
+ def base_transformer(geom, src_crs, dst_crs):
39
+ """transform a geometry from from one CRS to another
40
+
41
+ from https://geopandas.org/en/stable/docs/user_guide/reproject_fiona.html#fiona-example
42
+
43
+ helper function for transform_geodataframe()
44
+ """
45
+ return shape(
46
+ transform_geom(
47
+ src_crs=crs_to_fiona(src_crs),
48
+ dst_crs=crs_to_fiona(dst_crs),
49
+ geom=mapping(geom),
50
+ antimeridian_cutting=True,
51
+ antimeridian_offset=100.0,
52
+ )
53
+ )
54
+
55
+
56
+ def transform_geodataframe(
57
+ gdf: gpd.GeoDataFrame, src_crs: str, dst_crs: str
58
+ ) -> gpd.GeoDataFrame:
59
+ forward_transformer = partial(base_transformer, src_crs=gdf.crs, dst_crs=dst_crs)
60
+ with fiona.Env(OGR_ENABLE_PARTIAL_REPROJECTION="YES"):
61
+ gdf_reproj = gdf.set_geometry(
62
+ gdf.geometry.apply(forward_transformer), crs=dst_crs
63
+ )
64
+ return gdf_reproj
@@ -13,9 +13,30 @@ import datetime
13
13
  from pyVPRM.meteorologies.met_base_class import met_data_handler_base
14
14
  from loguru import logger
15
15
 
16
+
16
17
  class met_data_handler(met_data_handler_base):
17
18
 
18
- def __init__(self, year, month, day, hour, bpath, mpi=False, keys=[]):
19
+ def __init__(
20
+ self,
21
+ year,
22
+ month,
23
+ day,
24
+ hour,
25
+ bpath,
26
+ fname_fmt_str="{year}_{month}.nc",
27
+ mpi=False,
28
+ keys=[],
29
+ ):
30
+ """construct a met_data_handler instance for monthly ERA5 data
31
+
32
+ ARGS:
33
+ fname_fmt_str (str): specifies the file name syntax. Must have
34
+ placeholders for year and month.
35
+ valid examples:
36
+ '{year}_{month}.nc'
37
+ 'ERA5_2mT_msdswrf_ssrd_NZ_{year:04d}_{month:02d}.nc'
38
+ """
39
+
19
40
  super().__init__()
20
41
  # Init with year, month, day, hour and the required era5 keys as given in the
21
42
  # keys_dict above
@@ -23,6 +44,7 @@ class met_data_handler(met_data_handler_base):
23
44
  self.this_month = 0
24
45
  self.this_year = 0
25
46
  self.bpath = bpath
47
+ self.fname_fmt_str = fname_fmt_str
26
48
  self.ds_in_t = None
27
49
  self.regridder = None
28
50
  self.mpi = mpi
@@ -109,23 +131,41 @@ class met_data_handler(met_data_handler_base):
109
131
  def _init_data_for_day(self):
110
132
  if (self.this_month != self.month) | (self.this_year != self.year):
111
133
  self.data = xr.open_dataset(
112
- os.path.join(self.bpath, "{}_{}.nc".format(self.year, self.month))
134
+ os.path.join(
135
+ self.bpath,
136
+ self.fname_fmt_str.format(year=self.year, month=self.month),
137
+ )
113
138
  )
114
139
  self.this_month = self.month
115
140
  self.this_year = self.year
116
141
  self.in_era5_grid = True
117
142
 
118
143
  if self.ds_in_t is None:
144
+ # determine whether data uses "lat" or "latitude"
145
+ if "lat" in self.data.coords:
146
+ latvar = "lat"
147
+ elif "latitude" in self.data.coords:
148
+ latvar = "latitude"
149
+ else:
150
+ raise ValueError("cannot locate 'lat' or 'latitude' values")
151
+ # determine whether data uses "lon" or "longitude"
152
+ if "lon" in self.data.coords:
153
+ lonvar = "lon"
154
+ elif "longitude" in self.data.coords:
155
+ lonvar = "longitude"
156
+ else:
157
+ raise ValueError("cannot locate 'lon' or 'longitude' values")
158
+
119
159
  self.ds_in_t = xr.Dataset(
120
160
  {
121
161
  "lat": (
122
162
  ["lat"],
123
- self.data["lat"].values,
163
+ self.data[latvar].values,
124
164
  {"units": "degrees_north"},
125
165
  ),
126
166
  "lon": (
127
167
  ["lon"],
128
- self.data["lon"].values,
168
+ self.data[lonvar].values,
129
169
  {"units": "degrees_east"},
130
170
  ),
131
171
  }
@@ -5,10 +5,10 @@ Evergreen Forest:
5
5
  - 112
6
6
  - 121
7
7
  - 122
8
- tmin: -5
9
- topt: 20
10
- tmax: 40
11
- tlow: 1
8
+ tmin: -4
9
+ topt: 15
10
+ tmax: 38
11
+ tlow: -3
12
12
 
13
13
  Deciduous Forest:
14
14
  vprm_class: 2
@@ -17,11 +17,11 @@ Deciduous Forest:
17
17
  - 114
18
18
  - 123
19
19
  - 124
20
- tmin: 0
21
- topt: 20
22
- tmax: 40
23
- tlow: 5
24
-
20
+ tmin: 1
21
+ topt: 21
22
+ tmax: 37
23
+ tlow: 0
24
+
25
25
  Mixed Forest:
26
26
  vprm_class: 3
27
27
  class_numbers:
@@ -29,19 +29,19 @@ Mixed Forest:
29
29
  - 126
30
30
  - 116
31
31
  - 125
32
- tmin: -3
33
- topt: 20
34
- tmax: 40
35
- tlow: 2
32
+ tmin: -1
33
+ topt: 18
34
+ tmax: 38
35
+ tlow: 0
36
36
 
37
37
  Shrubland:
38
38
  vprm_class: 4
39
39
  class_numbers:
40
40
  - 20
41
- tmin: 2
42
- topt: 20
43
- tmax: 40
44
- tlow: 0
41
+ tmin: -1
42
+ topt: 19
43
+ tmax: 44
44
+ tlow: 2
45
45
 
46
46
  Savannas:
47
47
  vprm_class: 5
@@ -49,27 +49,27 @@ Savannas:
49
49
  - 999
50
50
  tmin: 0
51
51
  topt: 20
52
- tmax: 40
53
- tlow: 0
54
-
52
+ tmax: 40
53
+ tlow: 0
54
+
55
55
  Cropland:
56
56
  vprm_class: 6
57
57
  class_numbers:
58
58
  - 40
59
- tmin: -2
60
- topt: 22
61
- tmax: 40
62
- tlow: 2
63
-
59
+ tmin: -3
60
+ topt: 16
61
+ tmax: 50
62
+ tlow: -3
63
+
64
64
  Grassland:
65
65
  vprm_class: 7
66
66
  class_numbers:
67
67
  - 30
68
68
  - 100
69
- tmin: -3
70
- topt: 18
71
- tmax: 40
72
- tlow: 0
69
+ tmin: -2
70
+ topt: 17
71
+ tmax: 36
72
+ tlow: -2
73
73
 
74
74
  Other:
75
75
  vprm_class: 8
@@ -82,13 +82,13 @@ Other:
82
82
  tmin: 2
83
83
  topt: 18
84
84
  tmax: 40
85
- tlow: 0
85
+ tlow: -2
86
86
 
87
87
  Wetland:
88
88
  vprm_class: 9
89
89
  class_numbers:
90
90
  - 90
91
- tmin: 0
92
- topt: 20
91
+ tmin: -2
92
+ topt: 26
93
93
  tmax: 40
94
94
  tlow: 0
@@ -2,59 +2,66 @@ Evergreen Forest:
2
2
  vprm_class: 1
3
3
  class_numbers:
4
4
  - -1
5
- tmin: 0
6
- topt: 20
7
- tmax: 40
5
+ tmin: -4
6
+ topt: 15
7
+ tmax: 38
8
+ tlow: -3
8
9
 
9
10
  Deciduous Forest:
10
11
  vprm_class: 2
11
12
  class_numbers:
12
13
  - -1
13
- tmin: 0
14
- topt: 20
15
- tmax: 40
14
+ tmin: 1
15
+ topt: 21
16
+ tmax: 37
17
+ tlow: 0
16
18
 
17
19
 
18
20
  Mixed Forest:
19
21
  vprm_class: 3
20
22
  class_numbers:
21
23
  - 10
22
- tmin: 0
23
- topt: 20
24
- tmax: 40
24
+ tmin: -1
25
+ topt: 18
26
+ tmax: 38
27
+ tlow: 0
25
28
 
26
29
 
27
30
  Shrubland:
28
31
  vprm_class: 4
29
32
  class_numbers:
30
33
  - 20
31
- tmin: 2
32
- topt: 20
33
- tmax: 40
34
+ tmin: -1
35
+ topt: 19
36
+ tmax: 44
37
+ tlow: 2
34
38
 
35
39
  Savannas:
36
40
  vprm_class: 5
37
41
  class_numbers:
38
- - 126
39
- tmin: 2
42
+ - 999
43
+ tmin: 0
40
44
  topt: 20
41
- tmax: 40
45
+ tmax: 40
46
+ tlow: 0
42
47
 
43
48
  Cropland:
44
49
  vprm_class: 6
45
50
  class_numbers:
46
51
  - 40
47
- tmin: 5
48
- topt: 22
49
- tmax: 40
52
+ tmin: -3
53
+ topt: 16
54
+ tmax: 50
55
+ tlow: -3
50
56
 
51
57
  Grassland:
52
58
  vprm_class: 7
53
59
  class_numbers:
54
60
  - 30
55
- tmin: 2
56
- topt: 18
57
- tmax: 40
61
+ tmin: -2
62
+ topt: 17
63
+ tmax: 36
64
+ tlow: -2
58
65
 
59
66
  Other:
60
67
  vprm_class: 8
@@ -63,9 +70,18 @@ Other:
63
70
  - 60
64
71
  - 70
65
72
  - 80
66
- - 90
67
73
  - 95
68
74
  - 100
69
75
  tmin: 2
70
76
  topt: 18
71
77
  tmax: 40
78
+ tlow: -2
79
+
80
+ Wetland:
81
+ vprm_class: 9
82
+ class_numbers:
83
+ - 90
84
+ tmin: -2
85
+ topt: 26
86
+ tmax: 40
87
+ tlow: 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyVPRM
3
- Version: 3.0
3
+ Version: 5.0
4
4
  Summary: Vegetation Photosynthesis and Respiration Model
5
5
  Home-page: https://github.com/tglauch/pyVPRM/
6
6
  Author: Theo Glauch
@@ -36,5 +36,6 @@ Requires-Dist: lxml
36
36
  Requires-Dist: requests
37
37
  Requires-Dist: statsmodels
38
38
  Requires-Dist: loguru
39
+ Requires-Dist: fiona
39
40
 
40
41
  A tool to calculate the CO2 exchange flux between atmosphere and terrestrial biosphere using the Vegetation Photosynthesis and Respiration Model
@@ -15,6 +15,7 @@ pyVPRM/lib/downmodis.py
15
15
  pyVPRM/lib/fancy_plot.py
16
16
  pyVPRM/lib/flux_tower_class.py
17
17
  pyVPRM/lib/functions.py
18
+ pyVPRM/lib/reproject_fiona.py
18
19
  pyVPRM/lib/fluxnet_info/fluxnet_sites.pkl
19
20
  pyVPRM/lib/fluxnet_info/site_infos.txt
20
21
  pyVPRM/meteorologies/__init__.py
@@ -21,3 +21,4 @@ lxml
21
21
  requests
22
22
  statsmodels
23
23
  loguru
24
+ fiona
@@ -8,7 +8,7 @@ def readme():
8
8
 
9
9
  setup(
10
10
  name="pyVPRM",
11
- version="3.0",
11
+ version="5.0",
12
12
  description="Vegetation Photosynthesis and Respiration Model",
13
13
  long_description="A tool to calculate the CO2 exchange flux between atmosphere and terrestrial biosphere using the Vegetation Photosynthesis and Respiration Model",
14
14
  classifiers=[
@@ -48,6 +48,7 @@ setup(
48
48
  "requests",
49
49
  "statsmodels",
50
50
  "loguru",
51
+ "fiona",
51
52
  ],
52
53
  include_package_data=True,
53
54
  zip_safe=False,
@@ -1 +0,0 @@
1
- __version__ = "3.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes