Documentation for aalibrary
Modules:
| Name | Description |
|---|---|
config |
Used for storing environment-specific settings such as database URIs and |
ices_ship_names |
This file contains the code to parse through the ICES API found here: |
ingestion |
This file contains functions used to ingest Active Acoustics data into GCP |
conversion |
This file is used to store conversion functions for the AALibrary. |
metadata |
This file contains functions that have to do with metadata. |
queries |
This script contains classes that have SQL queries used for interaction |
config
Used for storing environment-specific settings such as database URIs and such.
ices_ship_names
This file contains the code to parse through the ICES API found here:
https://vocab.ices.dk/?ref=315
Specifically the SHIPC platform code which refers to ship names.
Functions:
| Name | Description |
|---|---|
get_all_ices_ship_codes_and_names |
Gets all of the ices ship codes and their corresponding names in a |
get_all_ices_ship_names |
Gets all of the ICES ship names. You can normalize them to our standards |
get_all_ship_info |
Gets all of the ship's info from the following URL: |
get_ices_code_from_ship_name |
Gets the ICES Code for a ship given a ship's name. |
get_all_ices_ship_codes_and_names(normalize_ship_names=False)
Gets all of the ices ship codes and their corresponding names in a dictionary format. The keys are the ICES code, and the name is the value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_ship_names
|
bool
|
Whether or not to format the ship name according to our own standards. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dict with all of the ICES ships. The keys are the ICES code, and the name is the value. |
Source code in src\aalibrary\ices_ship_names.py
get_all_ices_ship_names(normalize_ship_names=False)
Gets all of the ICES ship names. You can normalize them to our standards if you wish.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_ship_names
|
bool
|
Whether or not to format the ship name according to our own standards. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
List |
List
|
A list containing strings of all of the ship names. |
Source code in src\aalibrary\ices_ship_names.py
get_all_ship_info()
Gets all of the ship's info from the following URL: https:/vocab.ices.dk/services/api/Code/7f9a91e1-fb57-464a-8eb0-697e4b0235b5
Returns:
| Name | Type | Description |
|---|---|---|
List |
List
|
A list with dicts of all the ships, including name, ices code, uuids and other fields. |
Source code in src\aalibrary\ices_ship_names.py
get_ices_code_from_ship_name(ship_name='', is_normalized=False)
Gets the ICES Code for a ship given a ship's name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_name
|
str
|
The ship name string. Defaults to "". |
''
|
is_normalized
|
bool
|
Whether or not the ship name is already normalized according to aalibrary standards. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ICES Code if one has been found. Empty string if it has not. |
Source code in src\aalibrary\ices_ship_names.py
ingestion
This file contains functions used to ingest Active Acoustics data into GCP from various sources such as AWS buckets and Azure Data Lake.
Functions:
| Name | Description |
|---|---|
download_file_from_azure_directory |
Downloads a single file from an azure directory using the |
download_netcdf_file |
ENTRYPOINT FOR END-USERS |
download_raw_file |
ENTRYPOINT FOR END-USERS |
download_raw_file_from_azure |
ENTRYPOINT FOR END-USERS |
download_raw_file_from_ncei |
ENTRYPOINT FOR END-USERS |
download_specific_file_from_azure |
Creates a DataLakeFileClient and downloads a specific file from |
download_survey_from_ncei |
Downloads an entire survey from NCEI to a local directory while |
find_and_upload_survey_metadata_from_s3 |
Finds the metadata that is associated with a particular survey in s3, |
find_data_source_for_file |
Finds the data source of a given filename by checking all possible data |
download_file_from_azure_directory(directory_client, file_system='testcontainer', download_directory='./', file_path='')
Downloads a single file from an azure directory using the DataLakeDirectoryClient. Useful for numerous operations, as authentication is only required once for the creation of each DataLakeDirectoryClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory_client
|
DataLakeDirectoryClient
|
The DataLakeDirectoryClient that will be used to connect to a download from an azure file system in the data lake. |
required |
file_system
|
str
|
The file system (container) you wish to download your file from. Defaults to "testcontainer" for testing purposes. |
'testcontainer'
|
download_directory
|
str
|
The local directory you want to download to. Defaults to "./". |
'./'
|
file_path
|
str
|
The file path you want to download. |
''
|
Source code in src\aalibrary\ingestion.py
download_netcdf_file(raw_file_name='', file_type='netcdf', ship_name='', survey_name='', echosounder='', data_source='', file_download_directory='', gcp_bucket=None, debug=False)
ENTRYPOINT FOR END-USERS
Downloads a netcdf file from GCP storage bucket for use on your
workstation.
Works as follows:
1. Checks if the exact netcdf exists in gcp.
a. If it doesn't exists, prompts user to download it first.
b. If it exists, downloads to the file_download_directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_file_name
|
str
|
The raw file name (includes extension). Defaults to "". |
''
|
file_type
|
str
|
The file type (do not include the dot "."). Defaults to "netcdf". |
'netcdf'
|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used to gather the data. Defaults to "". |
''
|
data_source
|
str
|
The source of the file. Necessary due to the way the storage bucket is organized. Can be one of ["NCEI", "OMAO", "HDD"]. Defaults to "". |
''
|
file_download_directory
|
str
|
The local directory you want to store your file in. Defaults to "". |
''
|
gcp_bucket
|
bucket
|
The GCP bucket object used to download the file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\ingestion.py
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 | |
download_raw_file(file_name='', file_type='raw', ship_name='', survey_name='', echosounder='', data_source='', file_download_directory='.', gcp_bucket=None, debug=False)
ENTRYPOINT FOR END-USERS
Downloads a raw and idx file from NCEI for use on your workstation.
Works as follows:
1. Checks if raw file exists in GCP.
a. If it exists,
checks if a netcdf version also exists or not
lets the user know.
i. If force_download_from_ncei is True
downloads the raw and idx file from NCEI instead.
b. If it doesn't exist,
downloads .raw from NCEI and uploads to GCP for caching
downloads .idx from NCEI and uploads to GCP for caching
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
The file name (includes extension). Defaults to "". |
''
|
file_type
|
str
|
The file type (do not include the dot "."). Defaults to "". |
'raw'
|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used to gather the data. Defaults to "". |
''
|
data_source
|
str
|
The source of the file. Necessary due to the way the storage bucket is organized. Can be one of ["NCEI", "OMAO", "HDD"]. Defaults to "". |
''
|
file_download_directory
|
str
|
The local file directory you want to store your file in. Defaults to current directory. Defaults to ".". |
'.'
|
gcp_bucket
|
bucket
|
The GCP bucket object used to download the file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\ingestion.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 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 718 719 720 | |
download_raw_file_from_azure(file_name='', file_type='raw', ship_name='', survey_name='', echosounder='', data_source='OMAO', file_download_directory='.', config_file_path='', upload_to_gcp=False, debug=False)
ENTRYPOINT FOR END-USERS
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
The file name (includes extension). Defaults to "". |
''
|
file_type
|
str
|
The file type (do not include the dot "."). Defaults to "". |
'raw'
|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used to gather the data. Defaults to "". |
''
|
data_source
|
str
|
The source of the file. Necessary due to the way the storage bucket is organized. Can be one of ["NCEI", "OMAO", "HDD"]. Defaults to "". |
'OMAO'
|
file_download_directory
|
str
|
The local directory you want to store your file in. Defaults to current directory. Defaults to ".". |
'.'
|
config_file_path
|
str
|
The location of the config file.
Needs a |
''
|
upload_to_gcp
|
bool
|
Whether or not you want to upload to GCP. Defaults to False. |
False
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\ingestion.py
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 | |
download_raw_file_from_ncei(file_name='', file_type='raw', ship_name='', survey_name='', echosounder='', data_source='NCEI', file_download_directory='.', upload_to_gcp=False, debug=False)
ENTRYPOINT FOR END-USERS
Downloads a raw, idx, and bot file from NCEI. If upload_to_gcp is
enabled, the downloaded files will also upload to the GCP storage bucket
if they do not exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
The file name (includes extension). Defaults to "". |
''
|
file_type
|
str
|
The file type (do not include the dot "."). Defaults to "". |
'raw'
|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used to gather the data. Defaults to "". |
''
|
data_source
|
str
|
The source of the file. Necessary due to the way the storage bucket is organized. Can be one of ["NCEI", "OMAO", "HDD"]. Defaults to "". |
'NCEI'
|
file_download_directory
|
str
|
The local file directory you want to store your file in. Defaults to current directory. Defaults to ".". |
'.'
|
upload_to_gcp
|
bool
|
Whether or not you want to upload to GCP. Defaults to False. |
False
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\ingestion.py
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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
download_specific_file_from_azure(config_file_path='', container_name='testcontainer', file_path_in_container='')
Creates a DataLakeFileClient and downloads a specific file from
container_name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file_path
|
str
|
The location of the config file.
Needs a |
''
|
container_name
|
str
|
The container within Azure Data Lake you are trying to access. Defaults to "testcontainer". |
'testcontainer'
|
file_path_in_container
|
str
|
The file path of the file you would like downloaded. Defaults to "". |
''
|
Source code in src\aalibrary\ingestion.py
download_survey_from_ncei(ship_name='', survey_name='', download_directory='', max_limit=None, debug=False)
Downloads an entire survey from NCEI to a local directory while maintaining folder structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_name
|
str
|
The ship name. Defaults to "". |
''
|
survey_name
|
str
|
The name of the survey you would like to download. Defaults to "". |
''
|
download_directory
|
str
|
The directory to which the files
will be downloaded. Creates a directory in the cwd if not
specified. Defaults to "".
NOTE: The directory specified will have the |
''
|
max_limit
|
int
|
The maximum number of random files to download. Defaults to include all files. |
None
|
debug
|
bool
|
Whether or not you want to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\ingestion.py
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 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | |
find_and_upload_survey_metadata_from_s3(ship_name='', survey_name='', gcp_bucket=None, debug=False)
Finds the metadata that is associated with a particular survey in s3, then uploads all of those files into the correct gcp location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
gcp_bucket
|
bucket
|
The GCP bucket object used to download the file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\ingestion.py
conversion
This file is used to store conversion functions for the AALibrary.
Functions:
| Name | Description |
|---|---|
convert_local_raw_to_ices_netcdf |
ENTRYPOINT FOR END-USERS |
convert_local_raw_to_netcdf |
ENTRYPOINT FOR END-USERS |
convert_raw_to_netcdf |
ENTRYPOINT FOR END-USERS |
convert_raw_to_netcdf_ices |
ENTRYPOINT FOR END-USERS |
convert_local_raw_to_ices_netcdf(raw_file_location='', netcdf_file_download_directory='', echosounder='', delete_raw_after=False)
ENTRYPOINT FOR END-USERS Converts a local (on your computer) file from raw into netcdf using echopype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_file_location
|
str
|
The location of the raw file. Defaults to "". |
''
|
netcdf_file_download_directory
|
str
|
The location you want to download your netcdf file to. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used. Can be one of ["EK80", "EK70"]. Defaults to "". |
''
|
overwrite
|
bool
|
Whether or not to overwrite the netcdf file. Defaults to False. |
required |
delete_raw_after
|
bool
|
Whether or not to delete the raw file after conversion is complete. Defaults to False. |
False
|
Source code in src\aalibrary\conversion.py
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 | |
convert_local_raw_to_netcdf(raw_file_location='', netcdf_file_download_directory='', echosounder='', overwrite=False, delete_raw_after=False)
ENTRYPOINT FOR END-USERS Converts a local (on your computer) file from raw into netcdf using echopype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_file_location
|
str
|
The location of the raw file. Defaults to "". |
''
|
netcdf_file_download_directory
|
str
|
The location you want to download your netcdf file to. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used. Can be one of ["EK80", "EK70"]. Defaults to "". |
''
|
overwrite
|
bool
|
Whether or not to overwrite the netcdf file. Defaults to False. |
False
|
delete_raw_after
|
bool
|
Whether or not to delete the raw file after conversion is complete. Defaults to False. |
False
|
Source code in src\aalibrary\conversion.py
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 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
convert_raw_to_netcdf(file_name='', file_type='raw', ship_name='', survey_name='', echosounder='', data_source='', file_download_directory='', overwrite=False, delete_raw_after=False, gcp_bucket=None, is_metadata=False, debug=False)
ENTRYPOINT FOR END-USERS This function allows one to convert a file from raw to netcdf. Then uploads the file to GCP storage for caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
The file name (includes extension). Defaults to "". |
''
|
file_type
|
str
|
The file type (do not include the dot "."). Defaults to "". |
'raw'
|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used to gather the data. Defaults to "". |
''
|
data_source
|
str
|
The source of the file. Necessary due to the way the storage bucket is organized. Can be one of ["NCEI", "OMAO", "HDD"]. Defaults to "". |
''
|
file_download_directory
|
str
|
The local directory you want to store your file in. Defaults to "". |
''
|
overwrite
|
bool
|
Whether or not to overwrite the netcdf file. Defaults to False. |
False
|
delete_raw_after
|
bool
|
Whether or not to delete the raw file after conversion is complete. Defaults to False. |
False
|
gcp_bucket
|
bucket
|
The GCP bucket object used to download the file. Defaults to None. |
None
|
is_metadata
|
bool
|
Whether or not the file is a metadata file. Necessary since files that are considered metadata (metadata json, or readmes) are stored in a separate directory. Defaults to False. |
False
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\conversion.py
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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
convert_raw_to_netcdf_ices(file_name='', file_type='raw', ship_name='', survey_name='', echosounder='', data_source='', file_download_directory='', overwrite=False, delete_raw_after=False, gcp_bucket=None, is_metadata=False, debug=False)
ENTRYPOINT FOR END-USERS This function allows one to convert a file from raw to netcdf. Then uploads the file to GCP storage for caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
The file name (includes extension). Defaults to "". |
''
|
file_type
|
str
|
The file type (do not include the dot "."). Defaults to "". |
'raw'
|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
echosounder
|
str
|
The echosounder used to gather the data. Defaults to "". |
''
|
data_source
|
str
|
The source of the file. Necessary due to the way the storage bucket is organized. Can be one of ["NCEI", "OMAO", "HDD"]. Defaults to "". |
''
|
file_download_directory
|
str
|
The local directory you want to store your file in. Defaults to "". |
''
|
overwrite
|
bool
|
Whether or not to overwrite the netcdf file. Defaults to False. |
False
|
delete_raw_after
|
bool
|
Whether or not to delete the raw file after conversion is complete. Defaults to False. |
False
|
gcp_bucket
|
bucket
|
The GCP bucket object used to download the file. Defaults to None. |
None
|
is_metadata
|
bool
|
Whether or not the file is a metadata file. Necessary since files that are considered metadata (metadata json, or readmes) are stored in a separate directory. Defaults to False. |
False
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\conversion.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
metadata
This file contains functions that have to do with metadata.
Functions:
| Name | Description |
|---|---|
create_and_upload_metadata_df_for_netcdf |
Creates a metadata file with appropriate information for netcdf files. |
create_and_upload_metadata_df_for_raw |
Creates a metadata file with appropriate information. Then uploads it |
create_metadata_json_for_netcdf_files |
Creates a JSON object containing metadata for the current user. |
create_metadata_json_for_raw_files |
Creates a JSON object containing metadata for the current user. |
get_current_gcp_user_email |
Gets the current gcloud user's email. |
get_metadata_in_df_format |
Retrieves the metadata associated with all objects in GCP in DataFrame |
upload_ncei_metadata_df_to_bigquery |
Finds the metadata obtained from a survey on NCEI, and uploads it to the |
create_and_upload_metadata_df_for_netcdf(rf=None, debug=False)
Creates a metadata file with appropriate information for netcdf files. Then uploads it to the correct table in GCP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rf
|
RawFile
|
The RawFile object associated with this file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\metadata.py
create_and_upload_metadata_df_for_raw(rf=None, debug=False)
Creates a metadata file with appropriate information. Then uploads it to the correct table in GCP. Used for .raw files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rf
|
RawFile
|
The RawFile object associated with this file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print debug statements. Defaults to False. |
False
|
Source code in src\aalibrary\metadata.py
create_metadata_json_for_netcdf_files(rf=None, debug=False)
Creates a JSON object containing metadata for the current user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rf
|
RawFile
|
The RawFile object associated with this file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print out the metadata json. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The metadata dataframe for the |
Source code in src\aalibrary\metadata.py
create_metadata_json_for_raw_files(rf=None, debug=False)
Creates a JSON object containing metadata for the current user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rf
|
RawFile
|
The RawFile object associated with this file. Defaults to None. |
None
|
debug
|
bool
|
Whether or not to print out the metadata json. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The metadata dataframe for the |
Source code in src\aalibrary\metadata.py
get_current_gcp_user_email()
Gets the current gcloud user's email.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string containing the current gcloud user's email. |
Source code in src\aalibrary\metadata.py
get_metadata_in_df_format()
upload_ncei_metadata_df_to_bigquery(ship_name='', survey_name='', download_location='', s3_bucket=None)
Finds the metadata obtained from a survey on NCEI, and uploads it to the
ncei_cruise_metadata database table in bigquery. Also handles for extra
database entries that are needed, such as uploading to the
ncei_instrument_metadata when necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_name
|
str
|
The ship name associated with this survey. Defaults to "". |
''
|
survey_name
|
str
|
The survey name/identifier. Defaults to "". |
''
|
download_location
|
str
|
The local download location for the file. Defaults to "". |
''
|
s3_bucket
|
resource
|
The bucket resource object. Defaults to None. |
None
|
Source code in src\aalibrary\metadata.py
queries
This script contains classes that have SQL queries used for interaction with the metadata database in BigQuery.
Classes:
| Name | Description |
|---|---|
MetadataQueries |
This class contains queries related to the upload, alteration, and |
MetadataQueries
dataclass
This class contains queries related to the upload, alteration, and retrieval of metadata from our BigQuery instance.