depsi.io
IO methods:
io methods.
export_convex_hull_to_shapefile(stm, save_path, projection)
Export the convex hull of an STM to a shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stm
|
Dataset
|
The STM to export |
required |
save_path
|
str
|
Full path to where to save the shapefile, ending in .shp |
required |
projection
|
Literal['RD', 'WGS84']
|
Whether to output the convex hull in RD or in WGS84 |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
When an unknown projection is provided When the provided save_path does not end in .shp |
Source code in depsi/io.py
export_to_csv(stm, save_path, model_parameter_layer_names, ts_proj, point_annotation_label)
Export an STM to CSV-format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stm
|
Dataset
|
The STM to export |
required |
save_path
|
str
|
Full path to where to save the CSV |
required |
model_parameter_layer_names
|
tuple
|
Tuple with the layer names of the model parameters in the order that they will be stored in the csv |
required |
ts_proj
|
Literal['los', 'vertical']
|
Whether the saved time series is Line-of-Sight or projected onto the vertical |
required |
point_annotation_label
|
str
|
An extra annotation given to the point IDs in the CSV ( |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
|
ValueError
|
|
Source code in depsi/io.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | |
export_to_shapefile(stm, save_path, projection, model_parameter_layer_names, point_annotation_label)
Export an STM to a shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stm
|
Dataset
|
The STM to export |
required |
save_path
|
str
|
Full path to where to save the shapefile |
required |
projection
|
Literal['RD', 'WGS84']
|
Whether to output the shapefile in RD or in WGS84 (properties will contain both if available regardless, this only affects the coordinate system of the shapefile itself) |
required |
model_parameter_layer_names
|
tuple
|
Tuple with the layer names of the model parameters in the order that they will be stored in the csv |
required |
point_annotation_label
|
str
|
An extra annotation given to the point IDs in the CSV ( |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
|
ValueError
|
|
Source code in depsi/io.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 | |
export_to_skygeo_portal(stm, save_path, ts_proj, point_annotation_label, satellite, asc_dsc, azimuth_spacing, range_spacing)
Export an STM to CSV-format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stm
|
Dataset
|
The STM to export |
required |
save_path
|
str
|
Full path to where to save the CSV |
required |
ts_proj
|
Literal['los', 'vertical']
|
Whether the saved time series is Line-of-Sight or projected onto the vertical |
required |
point_annotation_label
|
str
|
An extra annotation given to the point IDs in the CSV ( |
required |
satellite
|
str
|
Name of the satellite that acquired the imagery |
required |
asc_dsc
|
Literal['asc', 'dsc']
|
Whether the viewing geometry is ascending or descending |
required |
azimuth_spacing
|
float
|
The pixel spacing in azimuth direction |
required |
range_spacing
|
float
|
The pixel spacing in range direction |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
|
ValueError
|
|
Source code in depsi/io.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | |
get_targets_from_slc(slc_stack, targets)
Extract target-matched data from a SLC stack.
This function matches given azimuth/range coordinates to the closest points in the SLC stack, extracts all data variables, and aligns detection_flag time series from the targets dataset with the SLC time dimension. Then return a Space-Time Matrix (STM) containing the aligned data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slc_stack
|
Dataset
|
Dataset containing SLC data with dimensions (azimuth, range, time), as well as variables like lat, lon, azimuth, range, etc. |
required |
targets
|
Dataset
|
A Space-Time Matrix containing target information with coordinates (space, time) and variables such as azimuth, range, target, and detection_flag. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
matching_scatterers |
Dataset
|
Dataset containing the extracted SLC data for matching targets. |
Notes
- detection_flag values are aligned to the SLC timestamps.
Source code in depsi/io.py
read_metadata(resfile, mode='raw', **kwargs)
Read metadata from a DORIS v5 resfile.
Modified from the original functions in: https://github.com/Pbaz98/Caroline-Radar-Coding-Toolbox/blob/main/gecoris/dorisUtils.py.
Source code in depsi/io.py
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 338 339 340 341 342 343 344 345 346 347 348 349 | |
read_rcs_csv(file_path)
Load an STM-like CSV resulting from the RadarCoding Toolbox.
Load an STM-like CSV resulting from the RadarCoding Toolbox, filter out metadata or header marked by '*' markers, and extract dates from the header.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the CSV file to load. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
The cleaned DataFrame containing the STM with 0/1 flags indicating the existence of the targets' data. |
list of str
|
A list of date strings extracted from the header. |
Source code in depsi/io.py
read_slc_stack(filename, engine='zarr', nlines_file=None, npixels_file=None, chunks=(500, 500))
Read a stack of SLCs into an xarray.Dataset.
Supports different engines for reading: - zarr: reads a zarr archive (default) - doris: reads using the doris engine
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Absolute filepath to the data archive (zarr folder or doris stack folder). |
required |
engine
|
str
|
Engine to use for reading the data. Defaults to 'zarr'. |
'zarr'
|
nlines_file
|
str
|
Required for doris engine. Path to the file containing number of lines in the stack. |
None
|
npixels_file
|
str
|
Required for doris engine. Path to the file containing number of pixels in the stack. |
None
|
chunks
|
tuple
|
Tuple specifying the chunk size for loading doris stacks (default is (500, 500)). |
(500, 500)
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Lazily loaded dataset with: - coordinates azimuth, range, lat, lon, time - variables h2ph, complex, amplitude, phase |
Source code in depsi/io.py
read_weather_data(filename, dates, requested_data_columns=('TG', 'RH'))
Read columns of a KNMI weather data file at specific dates into a dictionary.
The weather file is downloadable from https://www.knmi.nl/nederland-nu/klimatologie/daggegevens . Values that are
not available in the file are replaced by np.nan
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
absolute filepath to the KNMI weather data file |
required |
dates
|
list
|
list of datetime.datetime objects of days at which the data is to be returned |
required |
requested_data_columns
|
tuple
|
tuple of strings of the column names. Currently implemented: - "TG": average daily temperature [deg C] - "TN": minimum temperature [deg C] - "TX": maximum temperature [deg C] - "RH": total daily precipitation [mm] - "RXH": maximum hourly precipitation [mm] - "EV24": reference evapotranspiration following Makkink [mm] |
('TG', 'RH')
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with as keys the requested dates, as argument a dictionary with as keys requested columns, as |
argument the value
|
|