utils.py
This module contains utility functions that are used by the pipeline during the processing of a run.
_get_skyregion_relations(row, coords, ids)
¶
For each sky region row a list is returned that contains the ids of other sky regions that overlap with the row sky region (including itself).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | pd.Series | A row from the dataframe containing all the sky regions of the run. Contains the 'id', 'centre_ra', 'centre_dec' and 'xtr_radius' columns. | required |
coords | SkyCoord | A SkyCoord holding the coordinates of all sky regions. | required |
ids | pd.core.indexes.numeric.Int64Index | The sky regions ids that match the coords. | required |
Returns:
Type | Description |
---|---|
List[int] | A list of other sky regions (including self) that are within the |
List[int] | 'xtr_radius' of the sky region in the row. |
Source code in vast_pipeline/pipeline/utils.py
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
|
_load_measurements(image, cols, start_id=0, ini_df=False)
¶
Load the measurements for an image from the parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image | Image | The object representing the image for which to load the measurements. | required |
cols | List[str] | The columns to load. | required |
start_id | int | The number to start from when setting the source ids (when 'ini_df' is 'True'). Defaults to 0. | 0 |
ini_df | bool | Boolean to indicate whether these sources are part of the initial source list creation for association. If 'True' the source ids are reset ready for the first iteration. Defaults to 'False'. | False |
Returns:
Type | Description |
---|---|
pd.DataFrame | The measurements of the image with some extra values set ready for |
pd.DataFrame | association . |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
add_new_many_to_one_relations(row)
¶
This handles the relation information being created from the many_to_one function in advanced association. It is a lot simpler than the one_to_many case as it purely just adds the new relations to the relation column, taking into account if it is already a list of relations or not (i.e. no previous relations).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | pd.Series | The relation information Series from the association dataframe. Only the columns ['related_skyc1', 'new_relations'] are required. | required |
Returns:
Type | Description |
---|---|
List[int] | The new related field for the source in question, containing the |
List[int] | appended ids. |
Source code in vast_pipeline/pipeline/utils.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
add_new_one_to_many_relations(row, advanced=False, source_ids=None)
¶
This handles the relation information being created from the one_to_many functions in association.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | pd.Series | The relation information Series from the association dataframe. Only the columns ['related_skyc1', 'source_skyc1'] are required for advanced, these are instead called ['related', 'source'] for basic. | required |
advanced | bool | Whether advanced association is being used which changes the names of the columns involved. | False |
source_ids | Optional[pd.DataFrame] | A dataframe that contains the other ids to append to related for each original source. +----------------+--------+ | source_skyc1 | 0 | |----------------+--------| | 122 | [5542] | | 254 | [5543] | | 262 | [5544] | | 405 | [5545] | | 656 | [5546] | +----------------+--------+ | None |
Returns:
Type | Description |
---|---|
List[int] | The new related field for the source in question, containing the |
List[int] | appended ids. |
Source code in vast_pipeline/pipeline/utils.py
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 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
|
backup_parquets(p_run_path)
¶
Backups up all the existing parquet files in a pipeline run directory. Backups are named with a '.bak' suffix in the pipeline run directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_run_path | str | The path of the pipeline run where the parquets are stored. | required |
Returns:
Type | Description |
---|---|
None | None |
Source code in vast_pipeline/pipeline/utils.py
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 |
|
calc_ave_coord(grp)
¶
Calculates the average coordinate of the grouped by sources dataframe for each unique group, along with defining the image and epoch list for each unique source (group).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grp | pd.DataFrame | The current group dataframe (unique source) of the grouped by dataframe being acted upon. | required |
Returns:
Type | Description |
---|---|
pd.Series | A pandas series containing the average coordinate along with the |
pd.Series | image and epoch lists. |
Source code in vast_pipeline/pipeline/utils.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
|
calculate_m_metric(flux_a, flux_b)
¶
Calculate the m variability metric which is the modulation index between two fluxes. This is proportional to the fractional variability. See Section 5 of Mooley et al. (2016) for details, DOI: 10.3847/0004-637X/818/2/105.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flux_a | float | flux value "A". | required |
flux_b | float | flux value "B". | required |
Returns:
Name | Type | Description |
---|---|---|
float | float | the m metric for flux values "A" and "B". |
Source code in vast_pipeline/pipeline/utils.py
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 |
|
calculate_measurement_pair_metrics(df)
¶
Generate a DataFrame of measurement pairs and their 2-epoch variability metrics from a DataFrame of measurements. For more information on the variability metrics, see Section 5 of Mooley et al. (2016), DOI: 10.3847/0004-637X/818/2/105.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | Input measurements. Must contain columns: id, source, flux_int, flux_int_err, flux_peak, flux_peak_err, has_siblings. | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | pd.DataFrame: Measurement pairs and 2-epoch metrics. Will contain columns: source - the source ID id_a, id_b - the measurement IDs flux_int_a, flux_int_b - measurement integrated fluxes in mJy flux_int_err_a, flux_int_err_b - measurement integrated flux errors in mJy flux_peak_a, flux_peak_b - measurement peak fluxes in mJy/beam flux_peak_err_a, flux_peak_err_b - measurement peak flux errors in mJy/beam vs_peak, vs_int - variability t-statistic m_peak, m_int - variability modulation index |
Source code in vast_pipeline/pipeline/utils.py
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 |
|
calculate_vs_metric(flux_a, flux_b, flux_err_a, flux_err_b)
¶
Calculate the Vs variability metric which is the t-statistic that the provided fluxes are variable. See Section 5 of Mooley et al. (2016) for details, DOI: 10.3847/0004-637X/818/2/105.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flux_a | float | flux value "A". | required |
flux_b | float | flux value "B". | required |
flux_err_a | float | error of | required |
flux_err_b | float | error of | required |
Returns:
Name | Type | Description |
---|---|---|
float | float | the Vs metric for flux values "A" and "B". |
Source code in vast_pipeline/pipeline/utils.py
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 |
|
check_primary_image(row)
¶
Checks whether the primary image of the ideal source dataframe is in the image list for the source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | pd.Series | Input dataframe row, with columns ['primary'] and ['img_list']. | required |
Returns:
Type | Description |
---|---|
bool | True if primary in image list else False. |
Source code in vast_pipeline/pipeline/utils.py
876 877 878 879 880 881 882 883 884 885 886 887 888 |
|
create_measurement_pairs_arrow_file(p_run)
¶
Creates a measurement_pairs.arrow file using the parquet outputs of a pipeline run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_run | Run | Pipeline model instance. | required |
Returns:
Type | Description |
---|---|
None | None |
Source code in vast_pipeline/pipeline/utils.py
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
|
create_measurements_arrow_file(p_run)
¶
Creates a measurements.arrow file using the parquet outputs of a pipeline run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_run | Run | Pipeline model instance. | required |
Returns:
Type | Description |
---|---|
None | None |
Source code in vast_pipeline/pipeline/utils.py
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
|
cross_join(left, right)
¶
A convenience function to merge two dataframes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
left | pd.DataFrame | The base pandas DataFrame to merge. | required |
right | pd.DataFrame | The pandas DataFrame to merge to the left. | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | The resultant merged DataFrame. |
Source code in vast_pipeline/pipeline/utils.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
|
get_create_img(p_run, band_id, image)
¶
Function to fetch or create the Image and Sky Region objects for the images in the pipeline run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_run | Run | The pipeline run Django ORM object. | required |
band_id | int | The integer database id value of the frequency band of the image. | required |
image | Image | The image Django ORM object. | required |
Returns:
Type | Description |
---|---|
Image | The resulting image django ORM object, the sky region Django ORM |
SkyRegion | object and a bool value denoting if the image already existed in the |
bool | database. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
get_create_img_band(image)
¶
Return the existing Band row for the given FitsImage. An image is considered to belong to a band if its frequency is within some tolerance of the band's frequency. Returns a Band row or None if no matching band.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image | Image | The image Django ORM object. | required |
Returns:
Type | Description |
---|---|
Band | The band Django ORM object. |
Source code in vast_pipeline/pipeline/utils.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 |
|
get_create_p_run(name, path, description=None, user=None)
¶
Get or create a pipeline run in db, return the run django object and a flag True/False if has been created or already exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the pipeline run. | required |
path | str | The system path to the pipeline run folder which contains the configuration file and where outputs will be saved. | required |
description | str | An optional description of the pipeline run. | None |
user | User | The Django user that launched the pipeline run. | None |
Returns:
Type | Description |
---|---|
Run | The pipeline run object and a boolean object representing whether |
bool | the pipeline run already existed ('True') or not ('False'). |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
get_create_skyreg(p_run, image)
¶
This creates a Sky Region object in Django ORM given the related image object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_run | Run | The pipeline run Django ORM object. | required |
image | Image | The image Django ORM object. | required |
Returns:
Type | Description |
---|---|
SkyRegion | The sky region Django ORM object. |
Source code in vast_pipeline/pipeline/utils.py
40 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_eta_metric(row, df, peak=False)
¶
Calculates the eta variability metric of a source. Works on the grouped by dataframe using the fluxes of the associated measurements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | Dict[str, float] | Dictionary containing statistics for the current source. | required |
df | pd.DataFrame | The grouped by sources dataframe of the measurements containing all the flux and flux error information, | required |
peak | bool | Whether to use peak_flux for the calculation. If False then the integrated flux is used. | False |
Returns:
Type | Description |
---|---|
float | The calculated eta value. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
get_image_list_diff(row)
¶
Calculate the difference between the ideal coverage image list of a source and the actual observed image list. Also checks whether an epoch does in fact contain a detection but is not in the expected 'ideal' image for that epoch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | pd.Series | The row from the sources dataframe that is being iterated over. | required |
Returns:
Type | Description |
---|---|
List[str] | A list of the images missing from the observed image list. Will be |
List[str] | returned as '-1' integer value if there are no missing images. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
get_names_and_epochs(grp)
¶
Convenience function to group together the image names, epochs and datetimes into one list object which is then returned as a pandas series. This is necessary for easier processing in the ideal coverage analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grp | pd.DataFrame | A group from the grouped by sources DataFrame. | required |
Returns:
Type | Description |
---|---|
pd.Series | Pandas series containing the list object that contains the lists of the |
pd.Series | image names, epochs and datetimes. |
Source code in vast_pipeline/pipeline/utils.py
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
|
get_parallel_assoc_image_df(images, skyregion_groups)
¶
Merge the sky region groups with the images and skyreg_ids.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images | List[Image] | A list of the Image objects. | required |
skyregion_groups | pd.DataFrame | The sky region group of each skyregion id. +----+----------------+ | | skyreg_group | |----+----------------| | 2 | 1 | | 3 | 1 | | 1 | 2 | +----+----------------+ | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | Dataframe containing the merged images and skyreg_id and skyreg_group. |
pd.DataFrame | +----+-------------------------------+-------------+----------------+ |
pd.DataFrame | | | image | skyreg_id | skyreg_group | |
pd.DataFrame | |----+-------------------------------+-------------+----------------| |
pd.DataFrame | | 0 | VAST_2118+00A.EPOCH01.I.fits | 2 | 1 | |
pd.DataFrame | | 1 | VAST_2118-06A.EPOCH01.I.fits | 3 | 1 | |
pd.DataFrame | | 2 | VAST_0127-73A.EPOCH01.I.fits | 1 | 2 | |
pd.DataFrame | | 3 | VAST_2118-06A.EPOCH03x.I.fits | 3 | 1 | |
pd.DataFrame | | 4 | VAST_2118-06A.EPOCH02.I.fits | 3 | 1 | |
pd.DataFrame | | 5 | VAST_2118-06A.EPOCH05x.I.fits | 3 | 1 | |
pd.DataFrame | | 6 | VAST_2118-06A.EPOCH06x.I.fits | 3 | 1 | |
pd.DataFrame | | 7 | VAST_0127-73A.EPOCH08.I.fits | 1 | 2 | |
pd.DataFrame | +----+-------------------------------+-------------+----------------+ |
Source code in vast_pipeline/pipeline/utils.py
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 |
|
get_rms_noise_image_values(rms_path)
¶
Open the RMS noise FITS file and compute the median, max and min rms values to be added to the image model and then used in the calculations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rms_path | str | The system path to the RMS FITS image. | required |
Returns:
Type | Description |
---|---|
Tuple[float, float, float] | The median, minimum and maximum values of the RMS image. |
Raises:
Type | Description |
---|---|
IOError | Raised when the RMS FITS file cannot be found. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
get_src_skyregion_merged_df(sources_df, images_df, skyreg_df)
¶
Analyses the current sources_df to determine what the 'ideal coverage' for each source should be. In other words, what images is the source missing in when it should have been seen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sources_df | pd.DataFrame | The output of the association step containing the measurements associated into sources. | required |
images_df | pd.DataFrame | Contains the images of the pipeline run. I.e. all image objects for the run loaded into a dataframe. | required |
skyreg_df | pd.DataFrame | Contains the sky regions of the pipeline run. I.e. all sky region objects for the run loaded into a dataframe. | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | DataFrame containing missing image information. Output format: |
pd.DataFrame | +----------+----------------------------------+-----------+------------+ |
pd.DataFrame | | source | img_list | wavg_ra | wavg_dec | |
pd.DataFrame | |----------+----------------------------------+-----------+------------+ |
pd.DataFrame | | 278 | ['VAST_0127-73A.EPOCH01.I.fits'] | 22.2929 | -71.8717 | |
pd.DataFrame | | 702 | ['VAST_0127-73A.EPOCH01.I.fits'] | 28.8125 | -69.3547 | |
pd.DataFrame | | 844 | ['VAST_0127-73A.EPOCH01.I.fits'] | 17.3152 | -72.346 | |
pd.DataFrame | | 934 | ['VAST_0127-73A.EPOCH01.I.fits'] | 9.75754 | -72.9629 | |
pd.DataFrame | | 1290 | ['VAST_0127-73A.EPOCH01.I.fits'] | 20.8455 | -76.8269 | |
pd.DataFrame | +----------+----------------------------------+-----------+------------+ |
pd.DataFrame | ------------------------------------------------------------------+ skyreg_img_list | |
pd.DataFrame | ------------------------------------------------------------------+ ['VAST_0127-73A.EPOCH01.I.fits', 'VAST_0127-73A.EPOCH08.I.fits'] | ['VAST_0127-73A.EPOCH01.I.fits', 'VAST_0127-73A.EPOCH08.I.fits'] | ['VAST_0127-73A.EPOCH01.I.fits', 'VAST_0127-73A.EPOCH08.I.fits'] | ['VAST_0127-73A.EPOCH01.I.fits', 'VAST_0127-73A.EPOCH08.I.fits'] | ['VAST_0127-73A.EPOCH01.I.fits', 'VAST_0127-73A.EPOCH08.I.fits'] | |
pd.DataFrame | ------------------------------------------------------------------+ |
pd.DataFrame | ----------------------------------+------------------------------+ img_diff | primary | |
pd.DataFrame | ----------------------------------+------------------------------+ ['VAST_0127-73A.EPOCH08.I.fits'] | VAST_0127-73A.EPOCH01.I.fits | ['VAST_0127-73A.EPOCH08.I.fits'] | VAST_0127-73A.EPOCH01.I.fits | ['VAST_0127-73A.EPOCH08.I.fits'] | VAST_0127-73A.EPOCH01.I.fits | ['VAST_0127-73A.EPOCH08.I.fits'] | VAST_0127-73A.EPOCH01.I.fits | ['VAST_0127-73A.EPOCH08.I.fits'] | VAST_0127-73A.EPOCH01.I.fits | |
pd.DataFrame | ----------------------------------+------------------------------+ |
pd.DataFrame | ------------------------------+--------------+ detection | in_primary | |
pd.DataFrame | ------------------------------+--------------| VAST_0127-73A.EPOCH01.I.fits | True | VAST_0127-73A.EPOCH01.I.fits | True | VAST_0127-73A.EPOCH01.I.fits | True | VAST_0127-73A.EPOCH01.I.fits | True | VAST_0127-73A.EPOCH01.I.fits | True | |
pd.DataFrame | ------------------------------+--------------+ |
Source code in vast_pipeline/pipeline/utils.py
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 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 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
|
group_skyregions(df)
¶
Logic to group sky regions into overlapping groups. Returns a dataframe containing the sky region id as the index and a column containing a list of the sky region group number it belongs to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | A dataframe containing all the sky regions of the run. Only the 'id', 'centre_ra', 'centre_dec' and 'xtr_radius' columns are required. +------+-------------+--------------+--------------+ | id | centre_ra | centre_dec | xtr_radius | |------+-------------+--------------+--------------| | 2 | 319.652 | 0.0030765 | 6.72488 | | 3 | 319.652 | -6.2989 | 6.7401 | | 1 | 21.8361 | -73.121 | 7.24662 | +------+-------------+--------------+--------------+ | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | The sky region group of each skyregion id. |
pd.DataFrame | +----+----------------+ |
pd.DataFrame | | | skyreg_group | |
pd.DataFrame | |----+----------------| |
pd.DataFrame | | 2 | 1 | |
pd.DataFrame | | 3 | 1 | |
pd.DataFrame | | 1 | 2 | |
pd.DataFrame | +----+----------------+ |
Source code in vast_pipeline/pipeline/utils.py
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 |
|
groupby_funcs(df)
¶
Performs calculations on the unique sources to get the lightcurve properties. Works on the grouped by source dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | The current iteration dataframe of the grouped by sources dataframe. | required |
Returns:
Type | Description |
---|---|
pd.Series | Pandas series containing the calculated metrics of the source. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
parallel_groupby(df)
¶
Performs the parallel source dataframe operations to calculate the source metrics using Dask and returns the resulting dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | The sources dataframe produced by the previous pipeline stages. | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | The source dataframe with the calculated metric columns. |
Source code in vast_pipeline/pipeline/utils.py
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 721 722 |
|
parallel_groupby_coord(df)
¶
This function uses Dask to perform the average coordinate and unique image and epoch lists calculation. The result from the Dask compute is returned which is a dataframe containing the results for each source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | The sources dataframe produced by the pipeline. | required |
Returns:
Type | Description |
---|---|
pd.DataFrame | The resulting average coordinate values and unique image and epoch |
pd.DataFrame | lists for each unique source (group). |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
prep_skysrc_df(images, perc_error=0.0, duplicate_limit=None, ini_df=False)
¶
Initialise the source dataframe to use in association logic by reading the measurement parquet file and creating columns. When epoch based association is used it will also remove duplicate measurements from the list of sources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images | List[Image] | A list holding the Image objects of the images to load measurements for. | required |
perc_error | float | A percentage flux error to apply to the flux errors of the measurements. Defaults to 0. | 0.0 |
duplicate_limit | Optional[Angle] | The separation limit of when a source is considered a duplicate. Defaults to None in which case 2.5 arcsec is used in the 'remove_duplicate_measurements' function (usual ASKAP pixel size). | None |
ini_df | bool | Boolean to indicate whether these sources are part of the initial source list creation for association. If 'True' the source ids are reset ready for the first iteration. Defaults to 'False'. | False |
Returns:
Type | Description |
---|---|
pd.DataFrame | The measurements of the image(s) with some extra values set ready for |
pd.DataFrame | association and duplicates removed if necessary. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
reconstruct_associtaion_dfs(images_df_done, previous_parquet_paths)
¶
This function is used with add image mode and performs the necessary manipulations to reconstruct the sources_df and skyc1_srcs required by association.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images_df_done | pd.DataFrame | The images_df output from the existing run (from the parquet). | required |
previous_parquet_paths | Dict[str, str] | Dictionary that contains the paths for the previous run parquet files. Keys are 'images', 'associations', 'sources', 'relations' and 'measurement_pairs'. | required |
Returns:
Type | Description |
---|---|
Tuple[pd.DataFrame, pd.DataFrame] | The reconstructed sources_df and skyc1_srs dataframes. |
Source code in vast_pipeline/pipeline/utils.py
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 |
|
remove_duplicate_measurements(sources_df, dup_lim=None, ini_df=False)
¶
Remove perceived duplicate sources from a dataframe of loaded measurements. Duplicates are determined by their separation and whether this distances is within the 'dup_lim'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sources_df | pd.DataFrame | The loaded measurements from two or more images. | required |
dup_lim | Optional[Angle] | The separation limit of when a source is considered a duplicate. Defaults to None in which case 2.5 arcsec is used (usual ASKAP pixel size). | None |
ini_df | bool | Boolean to indicate whether these sources are part of the initial source list creation for association. If 'True' the source ids are reset ready for the first iteration. Defaults to 'False'. | False |
Returns:
Type | Description |
---|---|
pd.DataFrame | The input sources_df with duplicate sources removed. |
Source code in vast_pipeline/pipeline/utils.py
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 |
|
Created: March 2, 2022