Core functionality¶
This module has both Spherical Harmonics Analysis and Spherical Harmonics Synthesis
Spherical Harmonic Analysis and Synthesis¶
gsha(f, method, grid=None, lmax=-9999)
¶
GSHA - Global Spherical Harmonic Analysis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
ndarray
|
global field of size \((l_{max} + 1) * 2 * l_{max}\) or \(l_{max} * 2 * l_{max}\) |
required |
method |
str
|
method to be used |
required |
grid |
str
|
choose between 'block' or 'cell'. Defaults to None. |
None
|
lmax |
int
|
maximum degree of development. Defaults to -9999. |
-9999
|
Returns:
Type | Description |
---|---|
np.ndarray: Clm, Slm in |C\S| format |
Raises:
Type | Description |
---|---|
ValueError
|
grid argument can only be 'block' or 'cell' |
ValueError
|
Grid type entered is not right |
TypeError
|
Invalid size of matrix F |
TypeError
|
GRID and METHOD must be strings |
ValueError
|
2nd Neumann method ONLY on a ''neumann''/''gauss'' GRID' |
ValueError
|
Block mean method ONLY on a ''block''/''cell'' GRID |
ValueError
|
Maximum degree of development is higher than number of rows of input. |
Uses
plm
, neumann
, iplm
, sc2cs
Source code in pyshbundle/gsha.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
GSHS(field, quant='none', grd='mesh', n=-9999, h=0, jflag=1)
¶
GSHS - Global Spherical Harmonic Synthesis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
_type_
|
set of SH coefficients, either in SC-triangle or CS-square format |
required |
quant |
str
|
defining the field quantity. Defaults to 'none'. |
'none'
|
grd |
str
|
defining the grid. Defaults to 'mesh'. |
'mesh'
|
n |
int
|
description. Defaults to -9999. |
-9999
|
h |
int
|
description. Defaults to 0. |
0
|
jflag |
int
|
description. Defaults to 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
f |
ndarray
|
the global field |
theRAD (): vector of co-latitudes [rad] |
||
lamRAD (): vector of longitudes [rad] |
Raises:
Type | Description |
---|---|
Exception
|
Check format of the field |
Exception
|
n must be scalar |
Exception
|
n must be integer |
Exception
|
Grid argument must be string |
Exception
|
description |
Uses
cs2sc
, normalklm
, plm
, eigengrav
, ispec
Todo
- Change general exceptions to specific and descriptive built-in ones
- using the not and then check is not always advisable
- Check how to document valid options
Source code in pyshbundle/gshs.py
91 92 93 94 95 96 97 98 99 100 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
Intro to Grace Data Driven Correction¶
GRACE_Data_Driven_Correction_Vishwakarma(F, cf, GaussianR, basins)
¶
summary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
_type_
|
a cell matrix with one column containing SH coefficients |
required |
cf |
_type_
|
the column in F that contains SH coefficients from GRACE |
required |
GaussianR |
_type_
|
radius of the Gaussian filter (recommened = 400) |
required |
basins |
_type_
|
mask functions of basin, a cell data format with one column and each entry is a 360 x 720 matrix with 1 inside the catchment and 0 outside |
required |
Raises:
Type | Description |
---|---|
Exception
|
corrected data-driven time-series (Least Squares fit method) |
Exception
|
corrected data-driven time-series (shift and amplify method) |
Exception
|
gaussian filtered GRACE TWS time-series for all the basins. |
Returns:
Name | Type | Description |
---|---|---|
_type_ |
description |
Todo
- TypeError
Source code in pyshbundle/GRACE_Data_Driven_Correction_Vishwakarma.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
deg_to_rad(deg)
¶
Converts angle from degree to radian
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deg |
float
|
Angle in degree |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
Angle in Radian |
Todo
- Inbuilt function available in numpy module
Source code in pyshbundle/GRACE_Data_Driven_Correction_Vishwakarma.py
73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
Hydrological Applications with GRACE¶
BasinAvg(data, path, c_rs, m, gs)
¶
Computes the TWSA time-series for a given basin shape file, using the SH data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Dataset
|
xarray dataset with format - {coordinates: [time, lat, lon], Data variables: [tws]} |
required |
path |
str
|
valid path to the basin shape file with extension (.shp) |
required |
c_rs |
crs
|
the crs into which the dataframe must be transformed (related to salem module) |
required |
m |
int
|
number of files read |
required |
gs |
float
|
grid size |
required |
Returns:
Name | Type | Description |
---|---|---|
xarray.Dataset: basin averaged values of TWS |
||
_type_ |
description |
Source code in pyshbundle/basin_avg.py
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
TWSCalc(data, lmax, gs, r, m)
¶
summary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ndarray
|
SC coefficients |
required |
lmax |
int
|
maximum degree |
required |
gs |
float
|
grid size |
required |
r |
_type_
|
description |
required |
m |
_type_
|
description |
required |
Source code in pyshbundle/tws_cal.py
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 85 86 87 |
|