STIC-JPL 1.1.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

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.

Potentially problematic release.


This version of STIC-JPL might be problematic. Click here for more details.

@@ -1,123 +0,0 @@
1
- from typing import Union
2
- import numpy as np
3
- import rasters as rt
4
- from rasters import Raster
5
-
6
- # gas constant for dry air in joules per kilogram per kelvin
7
- RD = 286.9
8
-
9
- # gas constant for moist air in joules per kilogram per kelvin
10
- RW = 461.5
11
-
12
- # specific heat of water vapor in joules per kilogram per kelvin
13
- CPW = 1846.0
14
-
15
- # specific heat of dry air in joules per kilogram per kelvin
16
- CPD = 1005.0
17
-
18
- def kelvin_to_celsius(T_K: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
19
- """
20
- convert temperature in kelvin to celsius.
21
- :param T_K: temperature in kelvin
22
- :return: temperature in celsius
23
- """
24
- return T_K - 273.15
25
-
26
- def celcius_to_kelvin(T_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
27
- """
28
- convert temperature in celsius to kelvin.
29
- :param T_C: temperature in celsius
30
- :return: temperature in kelvin
31
- """
32
- return T_C + 273.15
33
-
34
- def calculate_specific_humidity(
35
- Ea_Pa: Union[Raster, np.ndarray],
36
- Ps_Pa: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
37
- """
38
- Calculate the specific humidity of air as a ratio of kilograms of water to kilograms of air.
39
-
40
- Args:
41
- Ea_Pa (Union[Raster, np.ndarray]): Actual water vapor pressure in Pascal.
42
- surface_pressure_Pa (Union[Raster, np.ndarray]): Surface pressure in Pascal.
43
-
44
- Returns:
45
- Union[Raster, np.ndarray]: Specific humidity in kilograms of water per kilograms of air.
46
- """
47
- return ((0.622 * Ea_Pa) / (Ps_Pa - (0.387 * Ea_Pa)))
48
-
49
- def calculate_specific_heat(specific_humidity: Union[Raster, np.ndarray]):
50
- # calculate specific heat capacity of the air (Cp)
51
- # in joules per kilogram per kelvin
52
- # from specific heat of water vapor (CPW)
53
- # and specific heat of dry air (CPD)
54
- Cp_Jkg = specific_humidity * CPW + (1 - specific_humidity) * CPD
55
-
56
- return Cp_Jkg
57
-
58
- def calculate_air_density(
59
- surface_pressure_Pa: Union[Raster, np.ndarray],
60
- Ta_K: Union[Raster, np.ndarray],
61
- specific_humidity: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
62
- """
63
- Calculate air density.
64
-
65
- Parameters:
66
- surface_pressure_Pa (Union[Raster, np.ndarray]): Surface pressure in Pascal.
67
- Ta_K (Union[Raster, np.ndarray]): Air temperature in Kelvin.
68
- specific_humidity (Union[Raster, np.ndarray]): Specific humidity.
69
-
70
- Returns:
71
- Union[Raster, np.ndarray]: Air density in kilograms per cubic meter.
72
- """
73
- # numerator: Pa(N / m ^ 2 = kg * m / s ^ 2); denominator: J / kg / K * K)
74
- rhoD = surface_pressure_Pa / (RD * Ta_K)
75
-
76
- # calculate air density (rho) in kilograms per cubic meter
77
- rho = rhoD * ((1.0 + specific_humidity) / (1.0 + specific_humidity * (RW / RD)))
78
-
79
- return rho
80
-
81
- def SVP_kPa_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
82
- """
83
- Calculate the saturation vapor pressure in kiloPascal (kPa) from air temperature in Celsius.
84
-
85
- Parameters:
86
- Ta_C (Union[Raster, np.ndarray]): Air temperature in Celsius.
87
-
88
- Returns:
89
- Union[Raster, np.ndarray]: Saturation vapor pressure in kPa.
90
-
91
- """
92
- SVP_kPa = np.clip(0.611 * np.exp((Ta_C * 17.27) / (Ta_C + 237.7)), 1, None)
93
-
94
- return SVP_kPa
95
-
96
- def SVP_Pa_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
97
- """
98
- Calculate the saturation vapor pressure in Pascal (Pa) from the air temperature in Celsius (Ta_C).
99
-
100
- Parameters:
101
- Ta_C (Union[Raster, np.ndarray]): Air temperature in Celsius.
102
-
103
- Returns:
104
- Union[Raster, np.ndarray]: Saturation vapor pressure in Pascal (Pa).
105
- """
106
- return SVP_kPa_from_Ta_C(Ta_C) * 1000
107
-
108
- def calculate_surface_pressure(elevation_m: Union[Raster, np.ndarray], Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
109
- """
110
- Calculate surface pressure using elevation and air temperature.
111
-
112
- Parameters:
113
- elevation_m (Union[Raster, np.ndarray]): Elevation in meters.
114
- Ta_K (Union[Raster, np.ndarray]): Air temperature in Kelvin.
115
-
116
- Returns:
117
- Union[Raster, np.ndarray]: Surface pressure in Pascal (Pa).
118
- """
119
- Ta_K = kelvin_to_celsius(Ta_C)
120
- Ps_Pa = 101325.0 * (1.0 - 0.0065 * elevation_m / Ta_K) ** (9.807 / (0.0065 * 287.0)) # [Pa]
121
-
122
- return Ps_Pa
123
-
@@ -1 +0,0 @@
1
- from .calculate_SEBAL_soil_heat_flux import calculate_SEBAL_soil_heat_flux
@@ -1,40 +0,0 @@
1
- from typing import Union
2
-
3
- import numpy as np
4
- import rasters as rt
5
- from rasters import Raster
6
-
7
- def calculate_SEBAL_soil_heat_flux(
8
- Rn: Union[Raster, np.ndarray],
9
- ST_C: Union[Raster, np.ndarray],
10
- NDVI: Union[Raster, np.ndarray],
11
- albedo: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
12
- """
13
- This function calculates the soil heat flux (G) in the Surface Energy Balance Algorithm for Land (SEBAL) model.
14
- The formula used in the function is a simplification of the more complex relationship between these variables in the energy balance at the surface.
15
-
16
- Parameters:
17
- Rn (np.ndarray): Net radiation at the surface.
18
- ST_C (np.ndarray): Surface temperature in Celsius.
19
- NDVI (np.ndarray): Normalized Difference Vegetation Index, indicating the presence and condition of vegetation.
20
- albedo (np.ndarray): Measure of the diffuse reflection of solar radiation.
21
-
22
- Returns:
23
- np.ndarray: The soil heat flux (G), a key component in the energy balance.
24
-
25
- Reference:
26
- "Evapotranspiration Estimation Based on Remote Sensing and the SEBAL Model in the Bosten Lake Basin of China" [^1^][1]
27
- """
28
- # Empirical coefficients used in the calculation
29
- coeff1 = 0.0038
30
- coeff2 = 0.0074
31
-
32
- # Vegetation cover correction factor
33
- NDVI_correction = 1 - 0.98 * NDVI ** 4
34
-
35
- # Calculation of the soil heat flux (G)
36
- G = Rn * ST_C * (coeff1 + coeff2 * albedo) * NDVI_correction
37
-
38
- G = rt.clip(G, 0, None)
39
-
40
- return G
@@ -1 +0,0 @@
1
- from .timer import *
STIC_JPL/timer/timer.py DELETED
@@ -1,77 +0,0 @@
1
- """
2
- This is a minimalistic performance timer.
3
- """
4
- import time
5
-
6
- __author__ = "Gregory Halverson"
7
-
8
- DEFAULT_FORMAT = "0.2f"
9
-
10
- class Timer(object):
11
- """
12
- This is a minimalistic performance timer.
13
- """
14
-
15
- def __init__(self):
16
- self._start_time = None
17
- self._end_time = None
18
- self.start()
19
-
20
- def __enter__(self, *args, **kwargs):
21
- self.start()
22
- return self
23
-
24
- def __exit__(self, *args, **kwargs):
25
- self.end()
26
-
27
- def __repr__(self):
28
- # print("Timer.__repr__")
29
- return self.__format__(format_string=DEFAULT_FORMAT)
30
-
31
- def __str__(self):
32
- # print("Timer.__str__")
33
- return self.__repr__()
34
-
35
- def __format__(self, format_string=DEFAULT_FORMAT):
36
- if format_string is None or format_string == "":
37
- format_string = DEFAULT_FORMAT
38
-
39
- return format(self.duration, format_string)
40
-
41
- @property
42
- def now(self):
43
- # return datetime.now()
44
- return time.perf_counter()
45
-
46
- def start(self):
47
- self._start_time = self.now
48
-
49
- return self.start_time
50
-
51
- @property
52
- def start_time(self):
53
- return self._start_time
54
-
55
- def end(self):
56
- self._end_time = self.now
57
-
58
- return self.end_time
59
-
60
- @property
61
- def end_time(self):
62
- return self._end_time
63
-
64
- @property
65
- def duration(self):
66
- if self.start_time is None:
67
- raise Exception("timer never started")
68
-
69
- if self.end_time is None:
70
- end_time = self.now
71
- else:
72
- end_time = self.end_time
73
-
74
- duration = end_time - self.start_time
75
-
76
- return duration
77
-
@@ -1 +0,0 @@
1
- from .vegetation_conversion import *
@@ -1,47 +0,0 @@
1
- from typing import Union
2
- import numpy as np
3
- import rasters as rt
4
- from rasters import Raster
5
-
6
- KPAR = 0.5
7
- MIN_FIPAR = 0.0
8
- MAX_FIPAR = 1.0
9
- MIN_LAI = 0.0
10
- MAX_LAI = 10.0
11
-
12
- def FVC_from_NDVI(NDVI: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
13
- """
14
- Convert Normalized Difference Vegetation Index (NDVI) to Fractional Vegetation Cover (FVC).
15
-
16
- Parameters:
17
- NDVI (Union[Raster, np.ndarray]): Input NDVI data.
18
-
19
- Returns:
20
- Union[Raster, np.ndarray]: Converted FVC data.
21
- """
22
- NDVIv = 0.52 # +- 0.03
23
- NDVIs = 0.04 # +- 0.03
24
- FVC = rt.clip((NDVI - NDVIs) / (NDVIv - NDVIs), 0.0, 1.0)
25
-
26
- return FVC
27
-
28
- def LAI_from_NDVI(
29
- NDVI: Union[Raster, np.ndarray],
30
- min_fIPAR: float = MIN_FIPAR,
31
- max_fIPAR: float = MAX_FIPAR,
32
- min_LAI: float = MIN_LAI,
33
- max_LAI: float = MAX_LAI) -> Union[Raster, np.ndarray]:
34
- """
35
- Convert Normalized Difference Vegetation Index (NDVI) to Leaf Area Index (LAI).
36
-
37
- Parameters:
38
- NDVI (Union[Raster, np.ndarray]): Input NDVI data.
39
-
40
- Returns:
41
- Union[Raster, np.ndarray]: Converted LAI data.
42
- """
43
- fIPAR = rt.clip(NDVI - 0.05, min_fIPAR, max_fIPAR)
44
- fIPAR = np.where(fIPAR == 0, np.nan, fIPAR)
45
- LAI = rt.clip(-np.log(1 - fIPAR) * (1 / KPAR), min_LAI, max_LAI)
46
-
47
- return LAI
@@ -1,28 +0,0 @@
1
- STIC_JPL/STIC_JPL.py,sha256=a0EpRTX6Sd75RPIqAzWckIuj9-KwbCE8T1aSEDpLM-c,17434
2
- STIC_JPL/__init__.py,sha256=FmTp-Ir0Wbae0SbZgxlNIxq48TDrWCev17Gv1hWskxU,216
3
- STIC_JPL/canopy_air_stream.py,sha256=UYp3l7mt0XH4SqvCGZhRzCIL-v7-Rvxxfm-C81lheSU,1637
4
- STIC_JPL/closure.py,sha256=AzWoLnpoZ1MlQAKq0CgpmCMfDGVsp8-hYZ50ry33cic,4031
5
- STIC_JPL/constants.py,sha256=xIVTsdc3_Rf3EPSgSk1QPjWiojFGn4lf1Swffov3oTM,595
6
- STIC_JPL/diagnostic.py,sha256=RXjtZbCEJMiTyRuiMGUvekDgO_GcrhXVXvorR0WlAsk,2613
7
- STIC_JPL/initialize_with_solar.py,sha256=6DUUHdVfeKvDk1pf_bOteSW8qd-n9pU4dowO1sMYOpw,3825
8
- STIC_JPL/initialize_without_solar.py,sha256=M_7QfP2pr2w5sQO7UOW1GPqxpmQkjmsQ526BgYVVALk,4675
9
- STIC_JPL/iterate_with_solar.py,sha256=WKySvuIJ4HzcDni0UYafmk5lXex2lJfde82kGnGUDI8,6368
10
- STIC_JPL/iterate_without_solar.py,sha256=09RERpN6tdZr6ORDhMwEFXwx8941vyn1HMJQ-Q_bY6s,6140
11
- STIC_JPL/net_radiation.py,sha256=Uwudsazul8V-x5t8KQLi3wpYi-wjMwT__eqZCRV2bIw,1187
12
- STIC_JPL/root_zone_initialization.py,sha256=3JVKNDt3ebIiGVfuhBawjKs-BicNwkbfMprkzSxd4Cg,1581
13
- STIC_JPL/root_zone_iteration.py,sha256=1XOMFE3-TdJZzUU5vouflUO4NKaZwAW6s1KJrNez3Es,3787
14
- STIC_JPL/soil_moisture_initialization.py,sha256=YF0GcHkpH5amABNPpxD8f1lLPRyIAkG2dYJTfEuIX4g,5599
15
- STIC_JPL/soil_moisture_iteration.py,sha256=QJXOPMxxwIIskpx9zLkXUPfuhWgFPUBcRnGhZo2UjAw,6493
16
- STIC_JPL/version.txt,sha256=rqWtvvV0eFJzxPOcG3aHz4AZk-DLa_Z4GkFonk7bsgw,5
17
- STIC_JPL/meteorology_conversion/__init__.py,sha256=dLF40imqJCC_l8_QMetbsj1YzkXZuFt9tQ2fsd7Wcdw,38
18
- STIC_JPL/meteorology_conversion/meteorology_conversion.py,sha256=8vzx71FLLNhR5v6EQBL8OSgAmupQcgdLX2c9tL9TPxA,4202
19
- STIC_JPL/soil_heat_flux/__init__.py,sha256=bN0dHUfqR9ob68M1TqdjQTK3kmaL5S4P08yK0Thub6k,74
20
- STIC_JPL/soil_heat_flux/calculate_SEBAL_soil_heat_flux.py,sha256=PZylUGET5-Uj6BGfhOeqS4tp2pGE__gdc5X1nidLjxw,1516
21
- STIC_JPL/timer/__init__.py,sha256=I_MQKp_aamBLUzZv0psEbRgs6GZLOJd4mmJ7bli0Ikc,21
22
- STIC_JPL/timer/timer.py,sha256=tn5e3NQmsh55Jp9Fstjf-8KJW4F8UIJs-d_ZLooFYE8,1610
23
- STIC_JPL/vegetation_conversion/__init__.py,sha256=8gnz0yK_euCV0TtVGDrSGaVfx4g0EJCG2J68ppuA5oc,37
24
- STIC_JPL/vegetation_conversion/vegetation_conversion.py,sha256=-K3FLV6pXkpxtRxQvimqqkXAgkn9mUUlHQ8FIscq1Zg,1306
25
- stic_jpl-1.1.0.dist-info/METADATA,sha256=sDO9vRDdU6d-qTxHfk-0ZoCLX5ZyT1o1F086M0hbqWA,5348
26
- stic_jpl-1.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
27
- stic_jpl-1.1.0.dist-info/top_level.txt,sha256=9NkchxttzACJcGcAaWzMaZarzX40OXQ216hERNA9LIo,9
28
- stic_jpl-1.1.0.dist-info/RECORD,,