From aaa52d9d51fabcc106e222f63b3bf3a8bb67ed83 Mon Sep 17 00:00:00 2001 From: "David P. Mayer" <dpmayer@usgs.gov> Date: Mon, 14 Jun 2021 21:02:12 -0700 Subject: [PATCH] Added GXP support to read_gpf() (#164) * Added GXP support to read_gpf() Modified read_gpf() in io_bae.py to support reading of either legacy Socet Set-style GPF files or new Socet GXP-style GPF files. Function now takes a boolean, `gxp` to flag whether function should interpret input file as SSET or GXP style, defaulst to SSET style for backwards compatibility. Removed unused variables from read_gpf(). Field names are now hard-coded in the function, rather than generated dynamically. The hints about field names in the GXP-style GPFs are just complicated enough that hard-coding a list of field names into the function was the simplest solution. Datatypes for each field were already hard-coded, so hard-coding the names is stylistically consistent. Partially address #24 * Deleted extraneous comment * Added tests for read_gpf() and updated Socet GXP test data * Updating test for read_gpf(), ticking minor version number * Fixing fixtures...maybe * Fixing fixtures...maybe * Correct variable assignment in read_gpf(), more fixing fixtures * Fixing test parameterization * More test parameterization tweaks --- plio/examples/SocetGXP/GXP_example_gpf.csv | 25 ++ plio/examples/SocetGXP/GXP_example_gpf.gpf | 174 +++++--- .../SocetGXP/GXP_example_wEigenValues.gpf | 391 ------------------ plio/io/io_bae.py | 83 ++-- plio/io/tests/test_io_bae.py | 63 ++- setup.py | 2 +- 6 files changed, 250 insertions(+), 488 deletions(-) create mode 100644 plio/examples/SocetGXP/GXP_example_gpf.csv delete mode 100644 plio/examples/SocetGXP/GXP_example_wEigenValues.gpf diff --git a/plio/examples/SocetGXP/GXP_example_gpf.csv b/plio/examples/SocetGXP/GXP_example_gpf.csv new file mode 100644 index 0000000..18d1af7 --- /dev/null +++ b/plio/examples/SocetGXP/GXP_example_gpf.csv @@ -0,0 +1,25 @@ +point_id,use,point_type,lat_Y_North,long_X_East,ht,sig0,sig1,sig2,res0,res1,res2,eigenval0,eigenvec0_i,eigenvec0_j,eigenvec0_k,eigenval1,eigenvec1_i,eigenvec1_j,eigenvec1_k,eigenval2,eigenvec2_i,eigenvec2_j,eigenvec2_k +ESP_011969_1425_REDmos_hijitreged_1,1,0,-37.52498315102231,-168.0378101351008,2166.8567751754185,0.0,0.0,0.0,0.0,0.0,0.0,0.010015,0.991258,-0.131935,-0.000733,0.017375,0.126817,0.951241,0.281173,103723.422751,0.036399,0.278808,-0.959657 +ESP_011969_1425_REDmos_hijitreged_10,1,0,-37.48836252421589,-168.12422875299504,2312.543966226925,0.0,0.0,0.0,0.0,0.0,0.0,0.009305,0.991449,-0.130497,-0.000525,0.017207,0.125904,0.955474,0.266867,102962.141334,0.034324,0.264651,-0.963733 +ESP_011969_1425_REDmos_hijitreged_12,1,0,-37.43168328052415,-168.06327026184894,561.0852310104716,0.0,0.0,0.0,0.0,0.0,0.0,0.009124,0.99128,-0.131771,-0.000682,0.017542,0.126781,0.952304,0.277567,105846.550937,0.035926,0.275233,-0.960706 +ESP_011969_1425_REDmos_hijitreged_13,1,0,-37.43513301191926,-168.0950838309726,846.8487925744189,0.0,0.0,0.0,0.0,0.0,0.0,0.008751,0.99136,-0.131167,-0.000616,0.01745,0.126384,0.95393,0.272111,105280.729204,0.035105,0.269838,-0.962266 +ESP_011969_1425_REDmos_hijitreged_14,1,0,-37.43831722012688,-168.11377673673576,1129.5974084590293,0.0,0.0,0.0,0.0,0.0,0.0,0.008804,0.991405,-0.130827,-0.000569,0.01738,0.126158,0.954852,0.268963,104835.518938,0.034644,0.266723,-0.96315 +ESP_011969_1425_REDmos_hijitreged_15,1,0,-37.43963846641856,-168.1376145220953,1650.4018031283986,0.0,0.0,0.0,0.0,0.0,0.0,0.009152,0.991457,-0.130433,-0.000504,0.017269,0.125897,0.955955,0.265143,104214.901264,0.034102,0.262941,-0.964209 +ESP_011969_1425_REDmos_hijitreged_16,1,0,-37.37941962448235,-168.05314041415602,1101.7481752817018,0.0,0.0,0.0,0.0,0.0,0.0,0.009776,0.991225,-0.132182,-0.00073,0.017479,0.127051,0.9512,0.281207,107150.383517,0.036476,0.278832,-0.959647 +ESP_011969_1425_REDmos_hijitreged_17,1,0,-37.38083863019242,-168.0675015475748,1181.9292023818236,0.0,0.0,0.0,0.0,0.0,0.0,0.009373,0.991264,-0.131894,-0.000703,0.017444,0.126862,0.951959,0.27871,106929.559928,0.036091,0.276365,-0.960375 +ESP_011969_1425_REDmos_hijitreged_18,1,0,-37.3846095508834,-168.10289468543252,1339.499132148808,0.0,0.0,0.0,0.0,0.0,0.0,0.008879,0.991349,-0.13125,-0.000596,0.017364,0.126444,0.953815,0.272486,106414.359157,0.035196,0.270204,-0.96216 +ESP_011969_1425_REDmos_hijitreged_19,1,0,-37.38667433736556,-168.12193972900008,1649.1213744038378,0.0,0.0,0.0,0.0,0.0,0.0,0.008908,0.991396,-0.130895,-0.000577,0.01729,0.126212,0.954743,0.269324,105962.787125,0.034702,0.26708,-0.963049 +ESP_011969_1425_REDmos_hijitreged_2,1,0,-37.53311540295684,-168.04751417198742,2027.9858571714208,0.0,0.0,0.0,0.0,0.0,0.0,0.009882,0.991283,-0.131745,-0.000716,0.017379,0.126707,0.951862,0.279112,103737.074825,0.03609,0.27677,-0.960258 +ESP_011969_1425_REDmos_hijitreged_20,1,0,-37.3877992288042,-168.14528733531682,2249.095866292016,0.0,0.0,0.0,0.0,0.0,0.0,0.009231,0.991447,-0.130512,-0.000505,0.017169,0.125955,0.955802,0.265664,105295.155262,0.03419,0.263455,-0.964066 +ESP_011969_1425_REDmos_hijitreged_22,1,0,-37.32506030406861,-168.08145197394458,2133.6427872475433,0.0,0.0,0.0,0.0,0.0,0.0,0.009867,0.991262,-0.131909,-0.000681,0.017285,0.126875,0.951997,0.278574,108618.424031,0.036098,0.276227,-0.960414 +ESP_011969_1425_REDmos_hijitreged_23,1,0,-37.3359911666688,-168.10133445338911,2231.769693690932,0.0,0.0,0.0,0.0,0.0,0.0,0.0094,0.991317,-0.131496,-0.00063,0.01724,0.126603,0.953115,0.27485,107858.649273,0.035541,0.272544,-0.961487 +ESP_011969_1425_REDmos_hijitreged_24,1,0,-37.34201630935803,-168.12810340862498,2075.5532688013145,0.0,0.0,0.0,0.0,0.0,0.0,0.009299,0.99138,-0.131017,-0.000576,0.017217,0.126313,0.954603,0.269775,107524.900384,0.034796,0.267523,-0.962923 +ESP_011969_1425_REDmos_hijitreged_25,1,0,-37.34819057995956,-168.14113429465988,2049.079113123323,0.0,0.0,0.0,0.0,0.0,0.0,0.009376,0.991414,-0.130757,-0.000546,0.017199,0.126146,0.955332,0.26726,107169.466479,0.034425,0.265034,-0.963624 +ESP_011969_1425_REDmos_hijitreged_3,1,0,-37.52839666893967,-168.07960079526694,1993.7697023377862,0.0,0.0,0.0,0.0,0.0,0.0,0.009467,0.991364,-0.131138,-0.000638,0.01733,0.126311,0.953542,0.273503,103419.214501,0.035258,0.271221,-0.961871 +ESP_011969_1425_REDmos_hijitreged_4,1,0,-37.53132150466094,-168.10855852614645,2020.7308455349735,0.0,0.0,0.0,0.0,0.0,0.0,0.009673,0.991433,-0.130616,-0.00055,0.017278,0.125974,0.955068,0.268284,103104.381955,0.034517,0.266055,-0.96334 +ESP_011969_1425_REDmos_hijitreged_5,1,0,-37.53630700111975,-168.1200506995373,2032.7915842058703,0.0,0.0,0.0,0.0,0.0,0.0,0.010626,0.991463,-0.130384,-0.000508,0.019453,0.125817,0.955697,0.266108,102983.822547,0.03421,0.2639,-0.963943 +ESP_011969_1425_REDmos_hijitreged_7,1,0,-37.47652424962241,-168.05120054627415,1095.661234358602,0.0,0.0,0.0,0.0,0.0,0.0,0.009388,0.991272,-0.131829,-0.000738,0.017494,0.126796,0.95187,0.279044,104702.232192,0.036083,0.276702,-0.960278 +ESP_011969_1425_REDmos_hijitreged_8,1,0,-37.48921839508181,-168.09323595053897,2009.226110327696,0.0,0.0,0.0,0.0,0.0,0.0,0.009011,0.99138,-0.131017,-0.000606,0.017301,0.126237,0.953951,0.272107,103466.816533,0.035073,0.269838,-0.962267 +ESP_011969_1425_REDmos_hijitreged_9,1,0,-37.48675126821804,-168.12128226770488,2354.6055057253534,0.0,0.0,0.0,0.0,0.0,0.0,0.009235,0.991445,-0.130527,-0.00054,0.017206,0.125915,0.955302,0.267476,102974.236379,0.034397,0.265255,-0.963564 +ESP_047190_1425_REDmos_hijitreged_4,1,0,-37.3298174143407,-168.14113733984277,2007.3591129511703,0.0,0.0,0.0,0.0,0.0,0.0,0.009566,0.991406,-0.130821,-0.000528,0.017203,0.126186,0.955203,0.267701,108124.644303,0.034516,0.265467,-0.963502 +ESP_047190_1425_REDmos_hijitreged_5,1,0,-37.33148587629012,-168.15425976288694,1985.726581414384,0.0,0.0,0.0,0.0,0.0,0.0,0.009763,0.991436,-0.130591,-0.000516,0.017183,0.126048,0.955894,0.265288,107981.903787,0.034151,0.263081,-0.964169 diff --git a/plio/examples/SocetGXP/GXP_example_gpf.gpf b/plio/examples/SocetGXP/GXP_example_gpf.gpf index c3e1801..196281d 100644 --- a/plio/examples/SocetGXP/GXP_example_gpf.gpf +++ b/plio/examples/SocetGXP/GXP_example_gpf.gpf @@ -18,115 +18,197 @@ GXP_Z_UNITS 3 GXP_Z_PRECISION 3 GXP_COORD_FORMAT 3 GXP_COORD_FORMAT_PRECISIONS 4 -22 -point_id,stat,known,lat_Y_North,long_X_East,ht,sig(3),res(3), eigenpair(val, vector)(3) -ESP_020297_2045_REDmos_hijitreged_8bit_1 0 0 -24.71012840659569 -18.80031897144174 29.99985045008361 +24 +point_id,use,point_type,lat_Y_North,long_X_East,ht,sig(3),res(3), eigenpair(val, vector)(3) +ESP_011969_1425_REDmos_hijitreged_1 1 0 +-37.52498315102231 -168.03781013510081 2166.85677517541853 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.010015 0.991258 -0.131935 -0.000733 +0.017375 0.126817 0.951241 0.281173 +103723.422751 0.036399 0.278808 -0.959657 -ESP_020297_2045_REDmos_hijitreged_8bit_2 0 0 -24.70421813707974 -18.78227519773831 44.99977570050396 +ESP_011969_1425_REDmos_hijitreged_10 1 0 +-37.48836252421589 -168.12422875299504 2312.54396622692502 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009305 0.991449 -0.130497 -0.000525 +0.017207 0.125904 0.955474 0.266867 +102962.141334 0.034324 0.264651 -0.963733 -ESP_020297_2045_REDmos_hijitreged_8bit_6 0 0 -24.63946455267877 -18.80461665321617 52.49973861814942 +ESP_011969_1425_REDmos_hijitreged_12 1 0 +-37.43168328052415 -168.06327026184894 561.08523101047160 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009124 0.991280 -0.131771 -0.000682 +0.017542 0.126781 0.952304 0.277567 +105846.550937 0.035926 0.275233 -0.960706 -ESP_020297_2045_REDmos_hijitreged_8bit_7 0 0 -24.65291347453150 -18.77556683928612 56.24972002062714 +ESP_011969_1425_REDmos_hijitreged_13 1 0 +-37.43513301191926 -168.09508383097261 846.84879257441889 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.008751 0.991360 -0.131167 -0.000616 +0.017450 0.126384 0.953930 0.272111 +105280.729204 0.035105 0.269838 -0.962266 -ESP_020297_2045_REDmos_hijitreged_8bit_8 0 0 -24.64911612548813 -18.73725571127163 58.12471073909546 +ESP_011969_1425_REDmos_hijitreged_14 1 0 +-37.43831722012688 -168.11377673673576 1129.59740845902934 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.008804 0.991405 -0.130827 -0.000569 +0.017380 0.126158 0.954852 0.268963 +104835.518938 0.034644 0.266723 -0.963150 -ESP_020297_2045_REDmos_hijitreged_8bit_9 0 0 -24.65136761105341 -18.71732124302701 59.06220608808508 +ESP_011969_1425_REDmos_hijitreged_15 1 0 +-37.43963846641856 -168.13761452209530 1650.40180312839857 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009152 0.991457 -0.130433 -0.000504 +0.017269 0.125897 0.955955 0.265143 +104214.901264 0.034102 0.262941 -0.964209 -ESP_020297_2045_REDmos_hijitreged_8bit_11 0 0 -24.56769120025294 -18.79705461409128 59.53095413767005 +ESP_011969_1425_REDmos_hijitreged_16 1 0 +-37.37941962448235 -168.05314041415602 1101.74817528170183 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009776 0.991225 -0.132182 -0.000730 +0.017479 0.127051 0.951200 0.281207 +107150.383517 0.036476 0.278832 -0.959647 -ESP_020297_2045_REDmos_hijitreged_8bit_12 0 0 -24.57226969675007 -18.76507418751966 59.76532814686288 +ESP_011969_1425_REDmos_hijitreged_17 1 0 +-37.38083863019242 -168.06750154757481 1181.92920238182364 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009373 0.991264 -0.131894 -0.000703 +0.017444 0.126862 0.951959 0.278710 +106929.559928 0.036091 0.276365 -0.960375 -ESP_020297_2045_REDmos_hijitreged_8bit_13 0 0 -24.58561888671209 -18.73491604381337 59.88251509185466 +ESP_011969_1425_REDmos_hijitreged_18 1 0 +-37.38460955088340 -168.10289468543252 1339.49913214880803 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.008879 0.991349 -0.131250 -0.000596 +0.017364 0.126444 0.953815 0.272486 +106414.359157 0.035196 0.270204 -0.962160 -ESP_020297_2045_REDmos_hijitreged_8bit_14 0 0 -24.58274568606691 -18.70979308436567 59.94110856574753 +ESP_011969_1425_REDmos_hijitreged_19 1 0 +-37.38667433736556 -168.12193972900008 1649.12137440383776 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.008908 0.991396 -0.130895 -0.000577 +0.017290 0.126212 0.954743 0.269324 +105962.787125 0.034702 0.267080 -0.963049 -ESP_020297_2045_REDmos_hijitreged_8bit_16 0 0 -24.49996538364011 -18.77588176749484 59.97040568709735 +ESP_011969_1425_REDmos_hijitreged_2 1 0 +-37.53311540295684 -168.04751417198742 2027.98585717142078 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009882 0.991283 -0.131745 -0.000716 +0.017379 0.126707 0.951862 0.279112 +103737.074825 0.036090 0.276770 -0.960258 -ESP_020297_2045_REDmos_hijitreged_8bit_17 0 0 -24.50035236811686 -18.76265916231216 59.98505424404698 +ESP_011969_1425_REDmos_hijitreged_20 1 0 +-37.38779922880420 -168.14528733531682 2249.09586629201613 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009231 0.991447 -0.130512 -0.000505 +0.017169 0.125955 0.955802 0.265664 +105295.155262 0.034190 0.263455 -0.964066 -ESP_020297_2045_REDmos_hijitreged_8bit_18 0 0 -24.50022968395651 -18.72672472647865 59.99237851949499 +ESP_011969_1425_REDmos_hijitreged_22 1 0 +-37.32506030406861 -168.08145197394458 2133.64278724754331 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009867 0.991262 -0.131909 -0.000681 +0.017285 0.126875 0.951997 0.278574 +108618.424031 0.036098 0.276227 -0.960414 -ESP_020297_2045_REDmos_hijitreged_8bit_19 0 0 -24.50913063816282 -18.69314202812970 59.99604062043176 +ESP_011969_1425_REDmos_hijitreged_23 1 0 +-37.33599116666880 -168.10133445338911 2231.76969369093194 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009400 0.991317 -0.131496 -0.000630 +0.017240 0.126603 0.953115 0.274850 +107858.649273 0.035541 0.272544 -0.961487 -ESP_020297_2045_REDmos_hijitreged_8bit_21 0 0 -24.42477602090075 -18.77789312511191 59.99787204831861 +ESP_011969_1425_REDmos_hijitreged_24 1 0 +-37.34201630935803 -168.12810340862498 2075.55326880131452 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009299 0.991380 -0.131017 -0.000576 +0.017217 0.126313 0.954603 0.269775 +107524.900384 0.034796 0.267523 -0.962923 -ESP_020297_2045_REDmos_hijitreged_8bit_22 0 0 -24.42459140840722 -18.75255600552742 59.99878776389185 +ESP_011969_1425_REDmos_hijitreged_25 1 0 +-37.34819057995956 -168.14113429465988 2049.07911312332317 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009376 0.991414 -0.130757 -0.000546 +0.017199 0.126146 0.955332 0.267260 +107169.466479 0.034425 0.265034 -0.963624 -ESP_020297_2045_REDmos_hijitreged_8bit_23 0 0 -24.44145496656833 -18.72170251844067 59.99924554787116 +ESP_011969_1425_REDmos_hijitreged_3 1 0 +-37.52839666893967 -168.07960079526694 1993.76970233778616 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009467 0.991364 -0.131138 -0.000638 +0.017330 0.126311 0.953542 0.273503 +103419.214501 0.035258 0.271221 -0.961871 -ESP_020297_2045_REDmos_hijitreged_8bit_24 0 0 -24.43565348607332 -18.70706758301213 59.99947445057103 +ESP_011969_1425_REDmos_hijitreged_4 1 0 +-37.53132150466094 -168.10855852614645 2020.73084553497347 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009673 0.991433 -0.130616 -0.000550 +0.017278 0.125974 0.955068 0.268284 +103104.381955 0.034517 0.266055 -0.963340 -ESP_028855_2045_REDmos_hijitreged_8bit_1 0 0 -24.69907377638699 -18.75251712669162 59.99958773031716 +ESP_011969_1425_REDmos_hijitreged_5 1 0 +-37.53630700111975 -168.12005069953730 2032.79158420587032 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.010626 0.991463 -0.130384 -0.000508 +0.019453 0.125817 0.955697 0.266108 +102983.822547 0.034210 0.263900 -0.963943 -ESP_028855_2045_REDmos_hijitreged_8bit_2 0 0 -24.69890626969526 -18.72546009282478 59.99964437624382 +ESP_011969_1425_REDmos_hijitreged_7 1 0 +-37.47652424962241 -168.05120054627415 1095.66123435860209 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009388 0.991272 -0.131829 -0.000738 +0.017494 0.126796 0.951870 0.279044 +104702.232192 0.036083 0.276702 -0.960278 -ESP_028855_2045_REDmos_hijitreged_8bit_3 0 0 -24.70412810503522 -18.69517420734698 59.99967268034787 +ESP_011969_1425_REDmos_hijitreged_8 1 0 +-37.48921839508181 -168.09323595053897 2009.22611032769601 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009011 0.991380 -0.131017 -0.000606 +0.017301 0.126237 0.953951 0.272107 +103466.816533 0.035073 0.269838 -0.962267 -ESP_028855_2045_REDmos_hijitreged_8bit_4 0 0 -24.62839745355714 -18.78438969632831 59.99968715603449 +ESP_011969_1425_REDmos_hijitreged_9 1 0 +-37.48675126821804 -168.12128226770488 2354.60550572535340 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +0.009235 0.991445 -0.130527 -0.000540 +0.017206 0.125915 0.955302 0.267476 +102974.236379 0.034397 0.265255 -0.963564 + +ESP_047190_1425_REDmos_hijitreged_4 1 0 +-37.32981741434070 -168.14113733984277 2007.35911295117035 +0.000000 0.000000 0.000000 +0.000000 0.000000 0.000000 +0.009566 0.991406 -0.130821 -0.000528 +0.017203 0.126186 0.955203 0.267701 +108124.644303 0.034516 0.265467 -0.963502 + +ESP_047190_1425_REDmos_hijitreged_5 1 0 +-37.33148587629012 -168.15425976288694 1985.72658141438410 +0.000000 0.000000 0.000000 +0.000000 0.000000 0.000000 +0.009763 0.991436 -0.130591 -0.000516 +0.017183 0.126048 0.955894 0.265288 +107981.903787 0.034151 0.263081 -0.964169 diff --git a/plio/examples/SocetGXP/GXP_example_wEigenValues.gpf b/plio/examples/SocetGXP/GXP_example_wEigenValues.gpf deleted file mode 100644 index 7a0607e..0000000 --- a/plio/examples/SocetGXP/GXP_example_wEigenValues.gpf +++ /dev/null @@ -1,391 +0,0 @@ -GROUND POINT FILE -COORD_SYSTEM 1 -ELLIPSOID WGS_84 -REFERENCE_DATUM_CODE WGS_84 -A_EARTH 6.37813700000000e+06 -E_EARTH 8.18191908426520e-02 -ELLIPSOID_CENTER 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 -DATUM_ROTATION 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 -DATUM_SCALE 1.00000000000000e+00 -DATUM_USE_APPROXIMATE 0 -VERTICAL_REFERENCE 0 -GEOID EGM96 -GXP_GEO_DELIM 0 -XY_UNITS 2 -Z_UNITS 1 -GXP_XY_UNITS 8 -GXP_Z_UNITS 3 -GXP_Z_PRECISION 3 -GXP_COORD_FORMAT 3 -GXP_COORD_FORMAT_PRECISIONS 4 -48 -point_id,use,point_type,lat_Y_North,long_X_East,ht,sig(3),res(3), eigenpair(val, vector)(3) -TP00000 1 0 -41.93625458705527 12.42204566561736 144.49352205921176 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158352 -0.256603 0.966155 -0.026455 -4.013993 -0.960305 -0.251760 0.120126 -53.055575 -0.109400 -0.056229 -0.992406 - -TP00001 1 0 -41.93614977329828 12.43532843201709 136.59798165897831 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.147683 0.254807 -0.966681 0.024523 -3.414512 0.966988 0.254800 -0.003446 -27.373052 -0.002918 0.024591 0.999693 - -TP00002 1 0 -41.93600868028481 12.44856883338915 131.02216550831190 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.148871 0.255942 -0.966423 0.022802 -3.415543 -0.966688 -0.255941 0.003003 -27.374026 0.002934 -0.022811 -0.999735 - -TP00003 1 0 -41.93582742159170 12.46183264196683 42.53414011227344 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.150899 0.256993 -0.966183 0.021083 -3.417682 -0.966409 -0.256998 0.002497 -27.382204 0.003005 -0.021016 -0.999775 - -TP00004 1 0 -41.93567874114391 12.47502042348289 33.55602926526246 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.152247 0.258079 -0.965930 0.019370 -3.418923 -0.966119 -0.258088 0.002047 -27.385266 0.003022 -0.019242 -0.999810 - -TP00005 1 0 -41.92472178814459 12.42183693476669 130.31661778917029 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.157670 -0.256362 0.966231 -0.026001 -4.004344 -0.959496 -0.251139 0.127660 -60.553692 -0.116819 -0.057675 -0.991477 - -TP00006 1 0 -41.92470541057641 12.43518102652992 131.01868421444289 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158204 -0.256749 0.966175 -0.024217 -4.004632 -0.959406 -0.251765 0.127104 -60.552628 -0.116708 -0.055868 -0.991594 - -TP00007 1 0 -41.92453014273798 12.44846601998071 127.84719080989689 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158866 -0.257113 0.966121 -0.022436 -4.005790 -0.959289 -0.252350 0.126823 -60.785186 -0.116865 -0.054131 -0.991672 - -TP00008 1 0 -41.92433137805049 12.46166940420497 30.74736690526817 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.160534 -0.257001 0.966191 -0.020645 -4.012666 -0.959247 -0.252441 0.126961 -61.043819 -0.117457 -0.052433 -0.991693 - -TP00009 1 0 -41.92427634347892 12.47490998351840 85.91462985892092 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.160841 -0.257664 0.966050 -0.018893 -4.012456 -0.959042 -0.253316 0.126765 -61.508008 -0.117675 -0.050782 -0.991753 - -TP00010 1 0 -41.91325814925960 12.42162422410620 111.08526281031884 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.157195 -0.256219 0.966281 -0.025551 -3.995906 -0.958592 -0.250603 0.135278 -69.732646 -0.124313 -0.059154 -0.990478 - -TP00011 1 0 -41.91306777375267 12.43497255749544 71.07172647683969 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158113 -0.256409 0.966276 -0.023759 -3.998100 -0.958525 -0.251034 0.134951 -69.859213 -0.124436 -0.057376 -0.990567 - -TP00012 1 0 -41.91305595851252 12.44827055547741 77.21713805424150 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158695 -0.256831 0.966206 -0.021988 -3.998856 -0.958407 -0.251696 0.134556 -70.038992 -0.124474 -0.055631 -0.990662 - -TP00013 1 0 -41.91288999074737 12.46154211897335 55.11252316723569 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.159644 -0.257111 0.966170 -0.020212 -4.001770 -0.958286 -0.252200 0.134472 -70.458269 -0.124825 -0.053944 -0.990711 - -TP00014 1 0 -41.91279779982322 12.47483596263755 58.62762288176800 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.160453 -0.257526 0.966095 -0.018442 -4.004223 -0.958125 -0.252835 0.134427 -70.996692 -0.125207 -0.052289 -0.990752 - -TP00015 1 0 -41.90175093485620 12.42148225018631 114.43877243398343 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.156653 -0.256344 0.966260 -0.025085 -3.987418 -0.957550 -0.250322 0.142957 -81.202843 -0.131854 -0.060667 -0.989411 - -TP00016 1 0 -41.90160211680926 12.43481091926831 53.85217634083486 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.157773 -0.256432 0.966281 -0.023306 -3.990594 -0.957506 -0.250663 0.142652 -81.319804 -0.132000 -0.058896 -0.989498 - -TP00017 1 0 -41.90153076575557 12.44803878473226 93.05768235343429 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158029 -0.257031 0.966163 -0.021543 -3.989536 -0.957343 -0.251513 0.142254 -81.708297 -0.132022 -0.057188 -0.989596 - -TP00018 1 0 -41.90136344034326 12.46138591063561 48.23743195698694 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.147870 0.253732 -0.967075 0.019622 -3.416066 -0.967264 -0.253583 0.009812 -26.906927 -0.004513 -0.021469 -0.999759 - -TP00019 1 0 -41.90131539062921 12.47457601739442 54.50425635362241 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.159981 -0.257629 0.966076 -0.018012 -3.995801 -0.957082 -0.252581 0.142117 -82.848770 -0.132746 -0.053852 -0.989686 - -TP00020 1 0 -41.89031609646010 12.42134431956200 116.37800224968522 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.156279 0.256633 -0.966196 0.024604 -3.980579 -0.956404 -0.250196 0.150640 -95.413649 0.139392 0.062190 0.988282 - -TP00021 1 0 -41.89016555985073 12.43471584940938 104.52095922234378 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.156932 -0.256977 0.966148 -0.022822 -3.981176 -0.956302 -0.250809 0.150268 -95.743932 -0.139457 -0.060440 -0.988382 - -TP00022 1 0 -41.89011177641125 12.44790360230068 105.97810466684170 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.157553 -0.257379 0.966081 -0.021069 -3.981964 -0.956180 -0.251471 0.149940 -96.164482 -0.139556 -0.058737 -0.988471 - -TP00023 1 0 -41.89002023627615 12.46121448638316 132.53702697409491 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158039 -0.257915 0.965975 -0.019296 -3.982295 -0.956006 -0.252263 0.149721 -96.902617 -0.139759 -0.057063 -0.988540 - -TP00024 1 0 -41.93849666397325 12.47967949366008 23.59177135678953 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.163327 0.257995 -0.965959 0.019010 -3.434059 -0.966146 -0.257967 0.003955 -27.174401 0.001084 -0.019387 -0.999811 - -TP00025 1 0 -41.92414607649729 12.43602541241768 106.83881396612762 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.157980 0.252786 -0.967228 0.023847 -3.431188 0.967522 0.252710 -0.006203 -27.140371 -0.000027 0.024641 0.999696 - -TP00026 1 0 -41.92452497153108 12.45035814650257 155.01454393707391 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.159952 0.254172 -0.966907 0.022082 -3.434409 -0.967152 -0.254193 0.001914 -27.485523 0.003762 -0.021843 -0.999754 - -TP00027 1 0 -41.92560548436217 12.46512362949083 45.70490813112367 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.163294 0.256203 -0.966411 0.020223 -3.438520 -0.966613 -0.256240 0.000796 -27.538393 0.004412 -0.019751 -0.999795 - -TP00028 1 0 -41.92611767780845 12.47949275696272 72.90424561314438 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.162023 0.257063 -0.966216 0.018572 -3.434102 -0.966395 -0.257023 0.004535 -27.158674 0.000392 -0.019114 -0.999817 - -TP00029 1 0 -41.91153545848729 12.42145251855246 95.25681018749083 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.156422 0.250603 -0.967763 0.025175 -3.431143 -0.968090 -0.250498 0.007296 -27.126976 0.000754 0.026200 0.999656 - -TP00030 1 0 -41.91214902852425 12.43595779250570 82.08069636271838 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.146089 0.252461 -0.967324 0.023402 -3.413987 -0.967604 -0.252330 0.008438 -27.048286 0.002257 0.024774 0.999691 - -TP00031 1 0 -41.91409526689853 12.47960070863084 64.46063944335870 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.161445 0.256314 -0.966424 0.018109 -3.434637 0.966594 0.256263 -0.005092 -27.148077 0.000281 0.018809 0.999823 - -TP00032 1 0 -41.89942123689374 12.42152904157943 89.64790394712833 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.143948 0.248430 -0.968332 0.024836 -3.414309 -0.968639 -0.248220 0.011233 -26.893338 0.004713 0.026848 0.999628 - -TP00033 1 0 -41.90158427105253 12.46506321094199 12.60274956770012 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.148570 0.254063 -0.966998 0.019154 -3.416830 -0.967177 -0.253920 0.009605 -26.914150 -0.004424 -0.020966 -0.999770 - -TP00034 1 0 -41.88791568134694 12.43607974088060 91.67279454306517 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.144290 0.250040 -0.967977 0.022349 -3.413236 -0.968206 -0.249786 0.013592 -26.710001 0.007574 0.025037 0.999658 - -TP00035 1 0 -41.88921685292129 12.46508373642658 66.89639385683545 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.159190 0.253222 -0.967222 0.018964 -3.435399 -0.967407 -0.253137 0.006787 -27.124714 -0.001764 -0.020064 -0.999797 - -TP00036 1 0 -41.93698613824719 12.45173434033437 97.54080927114951 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.149566 0.256280 -0.966342 0.022437 -3.416264 -0.966597 -0.256286 0.002659 -27.390795 0.003181 -0.022369 -0.999745 - -TP00037 1 0 -41.92544134714993 12.45186958425859 139.43876296079247 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158992 -0.257276 0.966087 -0.022022 -4.006400 -0.959317 -0.252598 0.126115 -60.186287 -0.116275 -0.053572 -0.991771 - -TP00038 1 0 -41.92535289565016 12.46652556357443 33.91479379321939 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.160867 -0.257165 0.966160 -0.020039 -4.014317 -0.959271 -0.252713 0.126233 -60.417160 -0.116897 -0.051686 -0.991798 - -TP00039 1 0 -41.91367601542850 12.45175020504941 56.02503836479827 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.159116 -0.256823 0.966218 -0.021547 -4.000871 -0.958450 -0.251768 0.134112 -69.514721 -0.124156 -0.055095 -0.990732 - -TP00040 1 0 -41.91379086289994 12.46648798525013 51.34057810933603 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.160029 -0.257234 0.966150 -0.019591 -4.003601 -0.958315 -0.252434 0.133827 -69.784539 -0.124352 -0.053199 -0.990811 - -TP00041 1 0 -41.90200032579178 12.45171854407266 73.86528192763012 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.158427 -0.257032 0.966173 -0.021074 -3.991259 -0.957375 -0.251596 0.141892 -81.237274 -0.131790 -0.056647 -0.989658 - -TP00042 1 0 -41.89035291253354 12.45180748059767 66.02497557535104 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 -3.146070 0.251787 -0.967568 0.020395 -3.414816 -0.967758 -0.251572 0.012508 -26.749234 -0.006972 -0.022887 -0.999714 - -TP00043 0 0 -41.88974071964977 12.47442595694094 0.52942276000977 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 - -TP00044 0 0 -41.93759665146908 12.46505118856630 79.52831268310547 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 - -TP00045 0 0 -41.90187433391595 12.47953785467674 79.52831268310547 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 - -TP00046 0 0 -41.88740100566574 12.42157468619255 79.52831268310547 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 - -TP00047 0 0 -41.88978202716761 12.47952708536319 79.52831268310547 -0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 - diff --git a/plio/io/io_bae.py b/plio/io/io_bae.py index 55d1832..b269bc8 100644 --- a/plio/io/io_bae.py +++ b/plio/io/io_bae.py @@ -3,7 +3,7 @@ import os import json from collections import defaultdict from functools import singledispatch - +from linecache import getline import numpy as np import pandas as pd @@ -193,61 +193,70 @@ def save_ipf(df, output_path): outIPF.close() return -def read_gpf(input_data): +def read_gpf(input_data,gxp=False): """ Read a socet gpf file into a pandas data frame Parameters ---------- - input_file : str + input_data : str path to the input data file + gxp : bool + Flag to notify function if input_data follows Socet GXP format. + Defaults is False (assume Socet Set format). + Returns ------- df : pd.DataFrame containing the gpf data with appropriate column names and indices """ - # Check that the number of rows is matching the expected number - with open(input_data, 'r') as f: - for i, l in enumerate(f): - if i == 1: - cnt = int(l) - elif i == 2: - col = l - break - - default_columns = np.genfromtxt(input_data, skip_header=2, dtype='unicode', - max_rows = 1, delimiter = ',') - - columns = [] - - for column in default_columns: - - if '(' in column and ')' in column: - column_name ,suffix = column.split('(') - num = int(suffix.split(')')[0]) + # line containing point count differs between Socet Set and Socet GXP gpf files + if not gxp: + l = 2 + else: + l = 21 - for column_num in range(int(num)): - new_column = '{}{}'.format(column_name, column_num) - columns.append(new_column); + cnt = getline(input_data, l) + cnt = int(cnt) + + # Lists of column names and their data types + if not gxp: + columns = ['point_id','stat','known','lat_Y_North','long_X_East','ht','sig0','sig1','sig2','res0','res1','res2'] + col_dtype = ['str','int32','int32','float64','float64','float64','float64','float64','float64','float64','float64','float64'] + else: + columns = ['point_id','use','point_type','lat_Y_North','long_X_East','ht','sig0','sig1','sig2','res0','res1','res2', + 'eigenval0','eigenvec0_i','eigenvec0_j', 'eigenvec0_k', + 'eigenval1','eigenvec1_i','eigenvec1_j', 'eigenvec1_k', + 'eigenval2','eigenvec2_i','eigenvec2_j', 'eigenvec2_k'] + col_dtype = ['str','int32','int32','float64','float64','float64','float64','float64','float64','float64','float64','float64', + 'float64','float64','float64','float64', + 'float64','float64','float64','float64', + 'float64','float64','float64','float64'] - else: - columns.append(column) + # Build dict of column names and their data types + dtype_dict = dict(zip(columns, col_dtype)) - # Mixed types requires read as unicode - let pandas soft convert - d = np.genfromtxt(input_data, skip_header=3, dtype='unicode') - d = d.reshape(-1, 12) + if not gxp: + # Mixed types requires read as unicode - let pandas soft convert + d = np.genfromtxt(input_data, skip_header=(l+1), dtype='unicode') + d = d.reshape(-1, len(columns)) + else: + # Read GXP-style GPF a block at a time + lmax=( (l+1) + ((cnt-1)*8) + 2 ) + for x in range(l+1,lmax,8): + a = np.genfromtxt(input_data, skip_header=(x), max_rows=4, dtype='unicode') + b = np.genfromtxt(input_data, skip_header=(x+4), max_rows=3, dtype='unicode') + if x == (l+1): + d = np.hstack([np.hstack(a),np.hstack(b)]) + else: + d = np.vstack(( d, np.hstack([np.hstack(a),np.hstack(b)])) ) df = pd.DataFrame(d, columns=columns) - # List of data types for columns in Socet set GPF file - col_dtype = ['str','int32','int32','float64','float64','float64','float64','float64','float64','float64','float64','float64'] - - # Build dict of column names and their data types - dtype_dict = dict(zip(columns, col_dtype)) - - # Hard conversion of data types to ensure 'point_id' is treated as string and 'stat' and 'known' flags treated as int + # Hard conversion of data types to ensure 'point_id' is treated as string and 'stat' and 'known' (GXP: 'use', 'point_type') + # flags treated as int df = df.astype(dtype_dict) # Validate the read data with the header point count diff --git a/plio/io/tests/test_io_bae.py b/plio/io/tests/test_io_bae.py index e3cc729..4031703 100644 --- a/plio/io/tests/test_io_bae.py +++ b/plio/io/tests/test_io_bae.py @@ -1,4 +1,4 @@ -'''import json +import json import os import numpy as np @@ -14,11 +14,15 @@ import pytest def insight_gpf(): return get_path('InSightE08_XW.gpf') +@pytest.fixture +def gxp_gpf(): + return get_path('GXP_example_gpf.gpf') + @pytest.fixture def example_str_id_gpf(): return get_path('InSightE08_string_id.gpf') -@pytest.fixture() +@pytest.fixture def insight_expected_gpf(): dtype_dict = {'point_id': 'str', 'stat': 'int32', @@ -35,6 +39,34 @@ def insight_expected_gpf(): return pd.read_csv(get_path('InSightE08_XW.csv'), dtype=dtype_dict) @pytest.fixture +def gxp_expected_gpf(): + dtype_dict = {'point_id': 'str', + 'use': 'int32', + 'point_type': 'int32', + 'lat_Y_North': 'float64', + 'long_X_East': 'float64', + 'ht': 'float64', + 'sig0': 'float64', + 'sig1': 'float64', + 'sig2': 'float64', + 'res0': 'float64', + 'res1': 'float64', + 'res2': 'float64', + 'eigenval0': 'float64', + 'eigenvec0_i': 'float64', + 'eigenvec0_j': 'float64', + 'eigenvec0_k': 'float64', + 'eigenval1': 'float64', + 'eigenvec1_i': 'float64', + 'eigenvec1_j': 'float64', + 'eigenvec1_k': 'float64', + 'eigenval2': 'float64', + 'eigenvec2_i': 'float64', + 'eigenvec2_j': 'float64', + 'eigenvec2_k': 'float64'} + return pd.read_csv(get_path('GXP_example_gpf.csv'), dtype=dtype_dict) + +'''@pytest.fixture def insight_ipf(): return get_path('P20_008845_1894_XN_09N203W.ipf') @@ -62,13 +94,18 @@ def insight_expected_ipf(): def test_read_ipf(ipf, expected): df = read_ipf(ipf) assert_frame_equal(df, expected) - -@pytest.mark.parametrize('gpf, expected', [(insight_gpf(),insight_expected_gpf())]) -def test_read_gpf(gpf, expected): - df = read_gpf(gpf) - assert_frame_equal(df, expected) - -@pytest.mark.parametrize('ipf, file', [(insight_ipf(), 'plio/io/tests/temp')]) +''' +# @pytest.mark.parametrize('gpf, expected', [ (get_path('InSightE08_XW.gpf'),insight_expected_gpf() ) ] ) +def test_read_gpf(insight_gpf, insight_expected_gpf): + df = read_gpf(insight_gpf) + assert_frame_equal(df, insight_expected_gpf) + +# @pytest.mark.parametrize('gpf, expected', [ (get_path('GXP_example_gpf.gpf'),gxp_expected_gpf() ) ] ) +def test_read_gxp_gpf(gxp_gpf, gxp_expected_gpf): + df = read_gpf(gxp_gpf,gxp=True) + assert_frame_equal(df, gxp_expected_gpf) + +'''@pytest.mark.parametrize('ipf, file', [(insight_ipf(), 'plio/io/tests/temp')]) def test_write_ipf(ipf, file): df = read_ipf(ipf) save_ipf(df, file) @@ -163,8 +200,8 @@ def test_write_str_id_gpf(gpf, file): # Test that every 5th line (the lines containing the point ID and integer flags) matches for i in range(3,len(fs),5): assert fs[i] == fl[i] - -@pytest.mark.parametrize('gpf', [(example_str_id_gpf())]) +''' +@pytest.mark.parametrize('gpf', [get_path('InSightE08_string_id.gpf')]) def test_gpf_dtypes(gpf): """ This test makes sure that a GPF whose point IDs only contain numbers @@ -182,7 +219,7 @@ def test_gpf_dtypes(gpf): # Check that the type of each column matches the truth list assert truth_dtypes == test_dtypes -@pytest.mark.parametrize('ipf', [(example_str_id_ipf())]) +'''@pytest.mark.parametrize('ipf', [(example_str_id_ipf())]) def test_ipf_dtypes(ipf): """ This test makes sure that a IPF whose point IDs only contain numbers @@ -244,4 +281,4 @@ B 1.0e-01 2.000000e+00 3.00000000000000e+00""" assert len(data['B']) == 3 assert data['B'] == [0.1, 2, 3] -''' \ No newline at end of file +''' diff --git a/setup.py b/setup.py index c0ba904..b1ead3c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ with open('README.md', 'r') as f: def setup_package(): setup( name = "plio", - version = '1.3.0', + version = '1.4.0', author = "USGS Astrogeology", author_email = "jlaura@usgs.gov", description = ("I/O API to support planetary data formats."), -- GitLab