utils
datetime_to_float(dates)
Convert a sequence of datetime objects to a float representation.
Output units are in days since the first item in dates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dates
|
Sequence[DateOrDatetime]
|
List of datetime objects to convert to floats |
required |
Returns:
| Name | Type | Description |
|---|---|---|
date_arr |
np.array 1D
|
The float representation of the datetime objects |
Source code in src/geepers/utils.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
decimal_year_to_datetime(decimal_year)
Convert a decimal year to a datetime object.
See https://geodesy.unr.edu/NGLStationPages/DecimalYearConvention for more information, or https://geodesy.unr.edu/NGLStationPages/decyr.txt for a mapping from decimal year to datetime (with hour precision).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decimal_year
|
float
|
Year expressed as a decimal (e.g., 2014.5). |
required |
Returns:
| Type | Description |
|---|---|
datetime
|
Corresponding calendar datetime (approximate to nearest day). |
Source code in src/geepers/utils.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
decimal_years_to_datetimes(decimal_years)
Vectorized version of decimal_year_to_datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decimal_years
|
array-like of float
|
Years expressed as decimals (e.g., [2014.5, 2014.5027]). |
required |
Returns:
| Type | Description |
|---|---|
DatetimeIndex
|
Corresponding calendar datetimes, using the same 365.25-day-year
convention as |
Source code in src/geepers/utils.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
get_cache_dir(force_posix=False, app_name='geepers')
Return the cache folder for the application.
The directory is used to store gps timeseries data. The default behavior is to return whatever is most appropriate for the OS.
the following folders could be returned:
Mac OS X:
~/Library/Application Support/geepers
Mac OS X (POSIX):
~/.geepers
Unix:
~/.cache/geepers
Unix (POSIX):
~/.geepers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_posix
|
bool
|
If this is set to |
False
|
app_name
|
str
|
Name of the application (for naming the subfolder) |
'geepers'
|
Returns:
| Name | Type | Description |
|---|---|---|
Path
|
Folder to store cached data. |
|
Starting source:
|
|
|
https |
//github.com/pallets/click/blob/ca5e1c3d75e95cbc70fa6ed51ef263592e9ac0d0/src/click/utils.py#L32
|
|
Source code in src/geepers/utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
get_dates(filename, fmt=DATE_FORMAT)
Search for dates in the stem of filename matching fmt.
Excludes dates that are not in the stem of filename (in the directories).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path or str
|
Path or string to search for dates. |
required |
fmt
|
str
|
Format of date to search for. Default is %Y%m%d |
DATE_FORMAT
|
Returns:
| Type | Description |
|---|---|
list[datetime]
|
list of dates found in the stem of |
Examples:
>>> get_dates("/path/to/20191231.slc.tif")
[datetime.datetime(2019, 12, 31, 0, 0)]
>>> get_dates("S1A_IW_SLC__1SDV_20191231T000000_20191231T000000_032123_03B8F1_1C1D.nc")
[datetime.datetime(2019, 12, 31, 0, 0), datetime.datetime(2019, 12, 31, 0, 0)]
>>> get_dates("/not/a/date_named_file.tif")
[]
Source code in src/geepers/utils.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
read_geo_csv(filename)
Read a CSV file with a geometry column.
Source code in src/geepers/utils.py
176 177 178 179 | |