m3_correction
M3-specific functions for testing
assign_loc(da, basename, usgs=2)
Return da with loc backplane assigned as 2D coords of (x, y).
Source code in roughness/m3_correction.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
|
bands2wls(da, basename)
Return da with M3 wavelength coordinate replacing bands.
Source code in roughness/m3_correction.py
1067 1068 1069 1070 1071 1072 1073 1074 1075 |
|
contin_remove(spec, wl1=2.537, wl2=2.657, divide=True)
Remove linear continuum fit between wl1 and wl2 from spec.
Source code in roughness/m3_correction.py
1367 1368 1369 1370 1371 1372 1373 |
|
emission_xr_helper(ind, args, kwargs)
Helper function for emission_xr.
Source code in roughness/m3_correction.py
100 101 102 103 104 105 106 |
|
ext2window(ext, transform)
Return rasterio window of data bounded by ext in dataset with transform.
Source code in roughness/m3_correction.py
901 902 903 904 905 906 907 908 909 910 911 |
|
furnsh_kernels(kernels_path=KERNELPATH)
Return spiceypy kernels for meta_path.
Source code in roughness/m3_correction.py
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
|
get_albedo_feng(lons, lats)
Return albedo interpolated from Feng et al. (2020) at lons, lats.
Source code in roughness/m3_correction.py
991 992 993 |
|
get_avg_spec(img, wlmin=0, wlmax=100000.0, wls=None)
Return the wavelengths and mean spectrum within the specified img array. Optionally specify min and max wavelengths to crop spectrum.
Source code in roughness/m3_correction.py
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 |
|
get_avg_sun_inc_az(obs, dem=None)
Return average solar incidence and azimuth from obs file.
Source code in roughness/m3_correction.py
379 380 381 382 383 384 |
|
get_dem_geotiff(fslo, fazim, felev, ext, width=None, height=None, resampling='nearest')
Return DEM geotiff from fslo, fazim, felev geotiff files.
Source code in roughness/m3_correction.py
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
|
get_dem_xr(fslope, fazimuth, felevation)
Return DEM as xarray from fslope, fazimuth, felevation
Source code in roughness/m3_correction.py
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 |
|
get_emission_xr(inc, iaz, em, eaz, alb, wls, tloc, ls, lat=None, **kwargs)
Return emission [W/(m^2 um)].
Source code in roughness/m3_correction.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
get_ls_spice(basename)
Return solar longitude (L_s) from basename.
Source code in roughness/m3_correction.py
1233 1234 1235 1236 |
|
get_m3_date(basename)
Return date object representing date of M3 observation
Source code in roughness/m3_correction.py
807 808 809 |
|
get_m3_directory(basename, dirpath='', level='L2')
Return PDS-like path to M3 observation, given basename and dirpath to m3 root directory.
Source code in roughness/m3_correction.py
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
|
get_m3_geom(obs, dem=None)
Return geometry array from M3 observation file and optional dem.
Source code in roughness/m3_correction.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
get_m3_geom_xr(obs, dem=None)
Return geometry from M3 observation file and optional dem as xarray.
Source code in roughness/m3_correction.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
get_m3_headers(basename, dirpath=M3PATH, flatdir=False, imgs=('rad', 'ref', 'obs', 'sup', 'loc'), usgs=0, usgspath='', ext='.HDR')
Return dict of paths to M3 header files for an observation.
See Also
https://astrogeology.usgs.gov/maps/ moon-mineralogy-mapper-geometric-data-restoration
Examples
get_m3_headers("M3G20090609T183254", dirpath="/path/to/m3") {'rad': '/path/to/m3/CH1M3_0003/DATA/20090415_20090816/200906/L1B/ M3G20090609T183254_V03_RDN.HDR', 'ref': '/path/to/m3/CH1M3_0004/DATA/20090415_20090816/200906/L2/ M3G20090609T183254_V01_RFL.HDR', 'obs': '/path/to/m3/CH1M3_0003/DATA/20090415_20090816/200906/L1B/ M3G20090609T183254_V03_OBS.HDR', 'sup': '/path/to/m3/CH1M3_0004/DATA/20090415_20090816/200906/L2/ M3G20090609T183254_V01_SUP.HDR', 'loc': '/path/to/m3/CH1M3_0003/DATA/20090415_20090816/200906/L1B/ M3G20090609T183254_V03_LOC.HDR'} get_m3_headers("M3G20090609T183254", dirpath="/path/to/imgs", flatdir=True) {'rad': '/path/to/imgs/M3G20090609T183254_V03_RDN.HDR', 'ref': '/path/to/imgs/M3G20090609T183254_V01_RFL.HDR', 'obs': '/path/to/imgs/M3G20090609T183254_V03_OBS.HDR', 'sup': '/path/to/imgs/M3G20090609T183254_V01_SUP.HDR', 'loc': '/path/to/imgs/M3G20090609T183254_V03_LOC.HDR'} get_m3_headers("M3G20090609T183254", dirpath="m3path", usgs=1, usgspath="usgspath") {'rad': 'm3path/CH1M3_0003/DATA/20090415_20090816/200906/L1B/ M3G20090609T183254_V03_RDN.HDR', 'ref': 'm3path/CH1M3_0004/DATA/20090415_20090816/200906/L2/ M3G20090609T183254_V01_RFL.HDR', 'obs': 'usgspath/boardman2014/M3G20090609T183254_V03_OBS.HDR', 'sup': 'm3path/CH1M3_0004/DATA/20090415_20090816/200906/L2/ M3G20090609T183254_V01_SUP.HDR', 'loc': 'usgspath/boardman2014/M3G20090609T183254_V03_LOC.HDR'}
Source code in roughness/m3_correction.py
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 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
|
get_m3_op(basename)
Return optical period of m3 observation based on date of observation
Source code in roughness/m3_correction.py
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 |
|
get_m3_res(basename)
Return the M3 spatial resolution in m/pixel which depends on the operational mode (Global or Target) and the spacecraft altitude (doubled in OP2C).
Source code in roughness/m3_correction.py
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 |
|
get_m3_tloc(obs, dem=None, lat=0)
Return average local time of M3 observation.
Source code in roughness/m3_correction.py
372 373 374 375 376 |
|
get_m3_warm(basename)
Return True if m3 observation was warm (Besse et al., 2013).
Source code in roughness/m3_correction.py
841 842 843 |
|
get_m3_wls(img)
Return wavelength array for an M3 image [microns].
Source code in roughness/m3_correction.py
387 388 389 390 391 392 393 394 395 |
|
get_m3albedo(rad, obs, i, e, g, basename, wlmin=0.55, wlmax=2, amax=0.4)
Return albedo (Bandfield et al. 2018)
Source code in roughness/m3_correction.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
|
get_m3photom(i, e, g, basename, newph=True, polish=False)
Return photometric correction factor, used to correct M3 radiance to i=30, e=0, g=30 using the M3 photometric correction.
Source code in roughness/m3_correction.py
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 |
|
get_m3xr(basename, img, usgs=2, dask=False, chunks=None, xoak=False)
Return m3 img (rad/ref/obs/sup/loc) as lazy loaded xarray.
Source code in roughness/m3_correction.py
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 |
|
get_photom(targeted, newph=True, m3ancpath=M3ANCPATH, m3apt=M3ALTPHOTOM)
cached
Return solar spectrum and alpha photometry tables as arrays.
Source code in roughness/m3_correction.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
|
get_photom_xr(targeted, *args, **kwargs)
Return xarray m3 photom
Source code in roughness/m3_correction.py
549 550 551 552 553 554 555 556 557 558 559 |
|
get_polish(targeted, iswarm=False, m3ancpath=M3ANCPATH)
cached
Return polish based on whether the detector was warm or cold.
Returns
polish_arr (np 1x1xN array)
Source code in roughness/m3_correction.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
|
get_polish_xr(targeted, *args, **kwargs)
Return xarray polish
Source code in roughness/m3_correction.py
584 585 586 587 588 589 590 591 |
|
get_solar_dist(basename, obs=None)
Get the solar distance subtracted off of M3 obs band 6.
Source code in roughness/m3_correction.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
get_solar_irradiance_xr(basename, obs)
Return m3 solar spectrum normalized by solar distance [W/(m^2 um)].
Source code in roughness/m3_correction.py
444 445 446 447 448 449 |
|
get_solar_spectrum(targeted=False, m3ancpath=M3ANCPATH)
cached
Return m3 solar spectrum [W/(m^2 um)].
Source code in roughness/m3_correction.py
423 424 425 426 427 428 429 430 431 432 |
|
get_solar_spectrum_xr(basename, m3ancpath=M3ANCPATH)
Return m3 solar spectrum [W/(m^2 um)].
Source code in roughness/m3_correction.py
435 436 437 438 439 440 441 |
|
get_spec(arr, wlmin=0, wlmax=100000.0, wls=None)
Return the wavelengths and spectrum of a 1D arr (1 pixel) of M3 data Optionally specify min and max wavelengths to crop spectrum
Source code in roughness/m3_correction.py
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 |
|
get_tloc_range_spice(basename, minlon, maxlon=None)
Return M3 min and max local time using spice. Gets start and end times from label file if found, else takes timestamp from the basename. In future could read actual times from TIM files (but range usually <0.1 lst for a given image).
Source code in roughness/m3_correction.py
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 |
|
ibd3um(spec, wl1=2.697, wl2=2.936)
Return 3um Integrated Band Depth from spec between (wl1, wl2). Equation 13 (Grumpe et al., 2019).
Source code in roughness/m3_correction.py
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 |
|
index_m3xoak(ds, opts=None)
Return ds with 2D xoak index set from loc file.
Source code in roughness/m3_correction.py
1126 1127 1128 1129 1130 1131 1132 |
|
is_targeted(m3img)
Return True if m3img has 256 bands (targeted mode) rather than 85.
Source code in roughness/m3_correction.py
619 620 621 622 623 624 625 626 627 628 |
|
lin_contin(spec, wl1=2.537, wl2=2.657)
Return slope and intercept of linear continuum between wl1 and wl2.
Source code in roughness/m3_correction.py
1359 1360 1361 1362 1363 1364 |
|
lon180(lon)
Convert lon to (-180, 180).
Source code in roughness/m3_correction.py
1252 1253 1254 |
|
lon360(lon)
Convert lon to (0, 360).
Source code in roughness/m3_correction.py
1247 1248 1249 |
|
lst2tloc(lst)
Return decimal local time [hr] from lst [hr,min,sec] (spice et2lst).
Source code in roughness/m3_correction.py
1206 1207 1208 |
|
m3_refl(basename, ext, wls=None, kwin=KWIN, kwre={})
Return M3 reflectance using the Tai Udovicic et al (2022) roughness thermal correction (updated from Bandfield et al., 2018). Uses ray-casting generated shadow_lookup table, KRC temperature table and applies standard M3 processing steps (empirical photometric correction).
Source code in roughness/m3_correction.py
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 |
|
m3_size_est(basename, ext)
Return estimates number of pixels from M3img name and extent.
Source code in roughness/m3_correction.py
926 927 928 929 930 931 932 933 934 935 |
|
m3_wl_to_ind(wl, img)
Get index and nearest wavelength of img given wl in nanometers.
Source code in roughness/m3_correction.py
1281 1282 1283 1284 1285 |
|
m3basename2utc(basename, fmt='%Y-%m-%dT%H:%M:%S')
Return UTC time from m3 basename.
Source code in roughness/m3_correction.py
1166 1167 1168 |
|
map_blocks(func, outda, *args, ind_dims=None, **kwargs)
Map func to blocks of args.
Source code in roughness/m3_correction.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
mpp2ppd(mpp, lat=0, Rmoon=1737.4)
Convert lunar meters / pixel to pixels / degree resolution at lat.
Source code in roughness/m3_correction.py
956 957 958 959 960 961 |
|
parse_envi_header(fname)
Return dictionary of parameters in the envi header.
TODO: port to open planetary package
Source code in roughness/m3_correction.py
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 |
|
read_albedo_map_feng(plot=False, falbedo=FALBEDO, amin=0.04, amax=0.22)
Return normal bolometric bond albedo albedo map from Feng et al. (2020).
https://doi.org/10.5281/zenodo.3575481
Source code in roughness/m3_correction.py
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 |
|
read_m3_geotiff(fname, ext, pad=False)
Return M3 image from file f with extent ext using rasterio.
Parameters
f (str): path to file ext (tuple): (latmin, latmax, lonmin, lonmax) pad (bool): pad image to match extent of ext
Source code in roughness/m3_correction.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
|
read_m3_geotiff_ext(fname, ext)
Read M3 geotiff with ext (minlon, maxlon, minlat, maxlat)
Source code in roughness/m3_correction.py
914 915 916 917 918 919 920 921 922 923 |
|
read_m3_image(hdr_path, ymin=0, ymax=None, xmin=0, xmax=None)
Return np.array() with subset of m3 image with rasterio. Assumes the image is in the same directory as the header in hdr_path.
Source code in roughness/m3_correction.py
846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
|
read_m3_rois(roi_path, sort_by_size=False)
Return dict of rois from roi_path.
Source code in roughness/m3_correction.py
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 |
|
readm3geotif_xr(fname, ext)
Read M3 geotiff and return xarray
Source code in roughness/m3_correction.py
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
|
rio2xy(arr)
Swap axes from [(bands), rows, columns] to [x, y, (bands)].
Source code in roughness/m3_correction.py
1257 1258 1259 1260 1261 1262 1263 |
|
rio_pad(arr, ext, w, transform, fill_value=np.nan)
Zero-pad a rasterio windowed read array to shape of full extent
Source code in roughness/m3_correction.py
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 |
|
sel_m3xoak(ds, lats, lons)
Return xarray of m3 data at lats, lons using xoak index.
Source code in roughness/m3_correction.py
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 |
|
sel_nearest(da, coord, x)
Return nearest coord value of each x (or index of x) in xarr.
Source code in roughness/m3_correction.py
1349 1350 1351 1352 1353 1354 1355 1356 |
|
subset_m3xr_ext(da, ext, fill_bb=False)
Return m3 da subsetted to lat/lon ext [minlon, maxlon, minlat, maxlat].
Source code in roughness/m3_correction.py
1091 1092 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 |
|
utc2lsmoon(utc)
Return solar longitude (L_s) [deg] from utc date using spiceypy.
Technically returns Earth's L_s since this is expected by KRC.
Source code in roughness/m3_correction.py
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
|
utc2lstmoon(utc, lon)
Return lunar local solar time at utc [yyyy-mm-ddThh:mm:ss] and lon [deg]. Uses spiceypy. Moon is NAIF ID 301.
Source code in roughness/m3_correction.py
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
|
utc2sdistmoon(utc)
Return solar distance [AU] from utc date using spiceypy.
Source code in roughness/m3_correction.py
1196 1197 1198 1199 1200 1201 1202 1203 |
|
wl_to_ind(wl, wavelengths)
Return index of wl in wavelengths.
Source code in roughness/m3_correction.py
1275 1276 1277 1278 |
|
xy2np(arr)
Swap axes from [x, y, (bands)] to [rows, columns, (bands)].
Source code in roughness/m3_correction.py
1266 1267 1268 1269 1270 1271 1272 |
|