diff --git a/plio/camera/__init__.py b/plio/camera/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/plio/camera/csm.py b/plio/camera/csm.py new file mode 100644 index 0000000000000000000000000000000000000000..b555efc6f23a08a40f25835a0fe2e6960a4e6ff6 --- /dev/null +++ b/plio/camera/csm.py @@ -0,0 +1,44 @@ +import datetime +import json + +try: + import usgscam as cam + from cycsm.isd import Isd + camera_support = True +except: + camera_support = False +import requests + +from plio.utils.utils import find_in_dict +from plio.io.io_json import NumpyEncoder + + +def data_from_cube(header): + data = {} + data['START_TIME'] = find_in_dict(header, 'StartTime') + data['SPACECRAFT_NAME'] = find_in_dict(header, 'SpacecraftName') + data['INSTRUMENT_NAME'] = find_in_dict(header, 'InstrumentId') + data['SAMPLING_FACTOR'] = find_in_dict(header, 'SpatialSumming') + data['SAMPLE_FIRST_PIXEL'] = find_in_dict(header, 'SampleFirstPixel') + data['IMAGE'] = {} + data['IMAGE']['LINES'] = find_in_dict(header, 'Lines') + data['IMAGE']['SAMPLES'] = find_in_dict(header, 'Samples') + data['TARGET_NAME'] = find_in_dict(header, 'TargetName') + data['LINE_EXPOSURE_DURATION'] = find_in_dict(header, 'LineExposureDuration') + data['SPACECRAFT_CLOCK_START_COUNT'] = find_in_dict(header, 'SpacecraftClockCount') + return data + +def create_camera(obj, url='http://smalls:8002/api/1.0/missions/mars_reconnaissance_orbiter/csm_isd'): + if not camera_support: + print("Usgscam library not installed. Camera capabilities are disabled") + + data = json.dumps(data_from_cube(obj.metadata), cls=NumpyEncoder) + r = requests.post(url, data=data) + + # Get the ISD back and instantiate a local ISD for the image + isd = r.json()['data']['isd'] + i = Isd.loads(isd) + + # Create the plugin and camera as usual + plugin = cam.genericls.Plugin() + return plugin.from_isd(i, plugin.modelname(0)) \ No newline at end of file diff --git a/plio/camera/tests/__init__.py b/plio/camera/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/plio/camera/tests/test_csm.py b/plio/camera/tests/test_csm.py new file mode 100644 index 0000000000000000000000000000000000000000..ce6cf12db5744def7593b0effe083b54fd5cd408 --- /dev/null +++ b/plio/camera/tests/test_csm.py @@ -0,0 +1,45 @@ +import datetime +import json +from unittest import mock + +import pytest +import pvl + +import usgscam + +from plio.camera import csm +from plio.examples import get_path + +def mock_requests_post(*args, **kwargs): + class MockResponse: + def __init__(self, json_data, status_code): + self.json_data = json_data + self.status_code = status_code + + def json(self): + return self.json_data + + if 'mars_reconnaissance_orbiter' in args[0]: + with open(get_path('ctx.response'), 'r') as f: + resp = json.load(f) + return MockResponse(resp, 200) + + return MockResponse(None, 404) + + +@pytest.fixture +def header(): + return pvl.load(get_path('ctx.pvl')) + +@pytest.fixture +def req_obj(): + return + +def test_data_from_cube(header): + data = csm.data_from_cube(header) + assert data['START_TIME'] == datetime.datetime(2008, 9, 17, 5, 8, 10, 820000) + +@mock.patch('requests.post', side_effect=mock_requests_post) +def test_create_camera(header): + cam = csm.create_camera(header) + assert isinstance(cam, usgscam.genericls.SensorModel) diff --git a/plio/examples/Pfeffernusse/ctx.response b/plio/examples/Pfeffernusse/ctx.response new file mode 100644 index 0000000000000000000000000000000000000000..fb991789b2e74675d4632fab13c9c5237a9cdb57 --- /dev/null +++ b/plio/examples/Pfeffernusse/ctx.response @@ -0,0 +1,1766 @@ +{ + "data": { + "isd": { + "DT_EPHEM": 0.15016, + "NUMBER_OF_EPHEM": 167, + "T0_QUAT": -12.493312001228333, + "MIN_VALID_HT": -8000, + "SEMI_MAJOR_AXIS": 3396190, + "QUATERNIONS": [ + 0.7544747178830865, + -0.08245247669844617, + 0.635600133866302, + 0.1413575572463973, + 0.7545184063283252, + -0.08246794004072511, + 0.6355485575771979, + 0.14134724736883675, + 0.7545618346371656, + -0.0824811079681164, + 0.6354975383699772, + 0.14133712627277414, + 0.7546062535657359, + -0.08249541898667778, + 0.6354453226579808, + 0.1413263946960781, + 0.7546513141292338, + -0.08251087532752066, + 0.635392261243477, + 0.14131533493435172, + 0.7546955993096182, + -0.08252613517469613, + 0.6353399729158357, + 0.14130501835083312, + 0.754739702910752, + -0.08254178172925768, + 0.6352876492141104, + 0.14129556919860936, + 0.7547835679751903, + -0.08255759383783626, + 0.6352356812488715, + 0.14128566269310724, + 0.7548273666908428, + -0.08257321134213136, + 0.6351839102436897, + 0.14127530368310023, + 0.7548716527716812, + -0.08258762393263974, + 0.6351316620179306, + 0.14126515535422166, + 0.754915441233571, + -0.08260088309607364, + 0.6350801034421806, + 0.14125520489787646, + 0.7549589605805332, + -0.08261427103887385, + 0.635028841483626, + 0.141245249632829, + 0.7550025284097999, + -0.0826283172733672, + 0.63497742835195, + 0.14123529574056726, + 0.755047036250494, + -0.08264397594274225, + 0.6349246475546628, + 0.14122548713779678, + 0.7550911737288111, + -0.08265848629050611, + 0.6348726149805769, + 0.14121493104035637, + 0.7551354623746996, + -0.08267301409415377, + 0.6348203658650418, + 0.14120449457333434, + 0.7551798853085483, + -0.08268793680827255, + 0.6347678985534745, + 0.14119405404536348, + 0.7552239940421632, + -0.08270373623464268, + 0.634715926354015, + 0.14118251899012788, + 0.7552683029589379, + -0.08271980763059497, + 0.6346634915783876, + 0.1411717975681172, + 0.7553120941915148, + -0.0827349274273269, + 0.6346116905180327, + 0.1411615188692295, + 0.7553552725184639, + -0.0827493744216572, + 0.6345606356095448, + 0.14115152512882093, + 0.7553995907379939, + -0.08276493532346989, + 0.634508163527323, + 0.14114111453065994, + 0.7554423601484117, + -0.08277835958303105, + 0.6344575334093663, + 0.14113193110789127, + 0.7554852572028881, + -0.08279088775890295, + 0.6344071817047422, + 0.14112130545961218, + 0.7555291112971552, + -0.08280525806507898, + 0.6343554445078694, + 0.14111067019375192, + 0.7555731829164613, + -0.08282059626552044, + 0.6343034502614763, + 0.14109942267103237, + 0.7556163474590952, + -0.08283531266791809, + 0.6342524092554903, + 0.1410890774701934, + 0.7556599131136736, + -0.0828492314689653, + 0.6342007243316812, + 0.14107991286929628, + 0.7557043744520859, + -0.0828635365279564, + 0.6341480852724822, + 0.1410699780013671, + 0.7557483232762175, + -0.08287700750752683, + 0.6340960699616013, + 0.14106043935503407, + 0.7557929214968596, + -0.08289079069511628, + 0.6340435957465119, + 0.14104926559898867, + 0.7558367048782659, + -0.08290469431175433, + 0.6339918454008604, + 0.1410390980723113, + 0.7558809543585366, + -0.08291958114161761, + 0.6339394813470965, + 0.1410285782765356, + 0.7559254201029384, + -0.08293650653579594, + 0.633886770751866, + 0.14101722232268488, + 0.7559685711587927, + -0.08295131496307702, + 0.6338354916759804, + 0.14100768864816665, + 0.7560127308354954, + -0.0829660262896552, + 0.6337831583727065, + 0.14099750869954372, + 0.7560568277786058, + -0.08298044600313903, + 0.6337308898041867, + 0.14098751029245657, + 0.7561002390554612, + -0.0829931936717266, + 0.6336795811749584, + 0.14097782345592938, + 0.7561443265087011, + -0.08300835091533418, + 0.6336274450621715, + 0.14096677633756344, + 0.7561878656759787, + -0.08302294275836768, + 0.6335758481831354, + 0.14095654429351365, + 0.756231257789459, + -0.08303692924621539, + 0.6335244242264512, + 0.14094664604762905, + 0.7562736707204019, + -0.08304889067896554, + 0.6334741695352903, + 0.1409379057019678, + 0.7563187252150236, + -0.08306473478293998, + 0.633420798423515, + 0.14092667543470444, + 0.7563632557617611, + -0.08307999376046364, + 0.6333677754160248, + 0.14091700051727654, + 0.7564075088425714, + -0.08309526746882225, + 0.6333153271998689, + 0.1409061866086204, + 0.7564519119611819, + -0.08311037538394818, + 0.6332626658857627, + 0.14089558683318806, + 0.7564954137974121, + -0.08312553086707751, + 0.633210786544523, + 0.14088624782147866, + 0.7565391870963509, + -0.08314045958420527, + 0.6331587640956489, + 0.14087619322153183, + 0.7565838130625056, + -0.08315566987726652, + 0.6331058551739819, + 0.14086534181083707, + 0.7566279337878894, + -0.08317186098328948, + 0.6330531309846166, + 0.14085575850145227, + 0.7566727270513637, + -0.0831873983854884, + 0.632999983001846, + 0.1408448167529391, + 0.7567171282317955, + -0.08320274849685766, + 0.6329471609573256, + 0.14083459063473808, + 0.7567619705792455, + -0.08321771211111136, + 0.6328938887539952, + 0.14082420904750267, + 0.7568049994572185, + -0.08323179203510006, + 0.6328426006693709, + 0.14081514254231578, + 0.7568490255688206, + -0.08324746020025738, + 0.6327902447372151, + 0.1408045419407658, + 0.7568945000610239, + -0.08326288694025831, + 0.632736356428673, + 0.14079314858725825, + 0.7569391220610717, + -0.08327829056149562, + 0.6326832404928642, + 0.14078284346474038, + 0.7569827128155463, + -0.08329377432588703, + 0.6326308306056357, + 0.14077482667077876, + 0.7570264328222157, + -0.08330674596096217, + 0.632578899758909, + 0.14076541359892045, + 0.7570705338759588, + -0.08332245194371117, + 0.632526355866497, + 0.14075505274450473, + 0.7571144413488324, + -0.08333795923355052, + 0.6324740228031168, + 0.1407448675123716, + 0.7571569798287417, + -0.08335219181960721, + 0.6324232647220782, + 0.14073568933910757, + 0.7572019910748159, + -0.08337287983249532, + 0.6323691115696485, + 0.14072460464817238, + 0.75724665259386, + -0.08338883609687366, + 0.6323161278187934, + 0.14071291216533685, + 0.7572913663818422, + -0.08340437988221133, + 0.632263005271376, + 0.14070176965907022, + 0.7573364992069972, + -0.08341955897987413, + 0.6322095685917201, + 0.14068996243358756, + 0.7573795594755252, + -0.083433755078907, + 0.6321585449402244, + 0.14067901571005714, + 0.7574238383279397, + -0.0834484251641056, + 0.6321060644274188, + 0.14066773896057932, + 0.7574686571416835, + -0.08346313451737011, + 0.6320529342951047, + 0.14065641426347547, + 0.7575115144752724, + -0.08347718549757506, + 0.6320020477712525, + 0.14064592618247485, + 0.7575556471459514, + -0.08349291445443911, + 0.631949330819224, + 0.14063576355364782, + 0.7576001811652177, + -0.08350820877964613, + 0.6318963505211463, + 0.14062484404578487, + 0.7576447191250696, + -0.08352361093910454, + 0.6318433498902362, + 0.14061389403992852, + 0.7576883101008075, + -0.08353890688899301, + 0.6317912642149824, + 0.1406039623695182, + 0.7577311398888704, + -0.0835521687197445, + 0.6317399570194084, + 0.1405958087926397, + 0.7577761464144555, + -0.083567924194116, + 0.6316860488614515, + 0.1405860933554667, + 0.757820225152073, + -0.08358336107853401, + 0.6316333147561, + 0.14057625614412403, + 0.757863949284822, + -0.08359789280931056, + 0.6315810932229965, + 0.14056653006850606, + 0.7579082282449514, + -0.08361235324464256, + 0.6315282605700041, + 0.14055656528571334, + 0.7579528834377495, + -0.08362864548173041, + 0.6314748045459995, + 0.14054624636355267, + 0.7579973302147286, + -0.08364467046296718, + 0.6314215686825955, + 0.1405361842832509, + 0.7580408580437263, + -0.08366037641037412, + 0.6313697511993955, + 0.1405248598135545, + 0.7580830933567978, + -0.08367313960727425, + 0.6313193601320637, + 0.14051581689365794, + 0.7581271963025853, + -0.08368868561174911, + 0.6312665912619467, + 0.14050568986159007, + 0.7581715855200278, + -0.0837037561892576, + 0.631213565489166, + 0.14049541932857065, + 0.7582168028154376, + -0.08371797602018899, + 0.6311598970216422, + 0.14048403756672548, + 0.7582595207230262, + -0.08373187157642535, + 0.6311089301079086, + 0.14047416578590677, + 0.7583033620291878, + -0.0837467346981996, + 0.631056553707063, + 0.1404639511973972, + 0.7583479637467734, + -0.08376193441409442, + 0.6310032741241578, + 0.14045345232113235, + 0.7583916786330065, + -0.08377729566466424, + 0.630950729173708, + 0.14044430877216807, + 0.7584346065979154, + -0.08379000166036704, + 0.6308994724205255, + 0.1404351766329357, + 0.7584786274553146, + -0.08380562027428844, + 0.6308465386946686, + 0.14042590331167507, + 0.7585226899067532, + -0.08382145224738621, + 0.6307935453736372, + 0.14041650955183246, + 0.7585673525232509, + -0.08383730334489949, + 0.6307396494823646, + 0.14040788020828865, + 0.7586104260187428, + -0.08385095665393008, + 0.6306880932092136, + 0.14039860287057246, + 0.7586546953672513, + -0.08386674809394895, + 0.6306349312552818, + 0.14038876465734437, + 0.7586986020884628, + -0.08388197352742567, + 0.6305822552517644, + 0.14037900508179782, + 0.7587424400917451, + -0.08389900072926279, + 0.6305292685308976, + 0.14036989992924695, + 0.7587859504547031, + -0.08391442074544748, + 0.6304765817328755, + 0.14036214329347438, + 0.7588297778752146, + -0.08392900638877815, + 0.6304240212724256, + 0.14035256855202077, + 0.7588733406163906, + -0.08394274447757612, + 0.6303718262999461, + 0.14034325476688433, + 0.758916850263095, + -0.08395806211824747, + 0.6303196739492045, + 0.14033305677801036, + 0.7589615549601177, + -0.08397257696802635, + 0.6302663802244145, + 0.14032196680734915, + 0.7590064079873978, + -0.0839874893528747, + 0.6302126632319999, + 0.1403117007533532, + 0.7590508483850037, + -0.08400231742251656, + 0.6301594700789153, + 0.1403013275187155, + 0.7590944796742115, + -0.08401815099354641, + 0.6301069835593529, + 0.14029151970627948, + 0.7591380560298586, + -0.08403338764815164, + 0.6300547490486844, + 0.14028119919925844, + 0.7591818090851171, + -0.08404756752476288, + 0.6300023152839054, + 0.14027141506500201, + 0.7592254200470141, + -0.08406182580488214, + 0.6299500652811165, + 0.14026149239581706, + 0.75926934613875, + -0.08407732138160583, + 0.6298970825631494, + 0.14025237759753836, + 0.7593139053280762, + -0.08409375831226576, + 0.6298432031328055, + 0.1402432617124648, + 0.7593579761867677, + -0.08410916156214643, + 0.6297901537620604, + 0.14023364491879017, + 0.7594022674213965, + -0.08412416683824787, + 0.629736940368755, + 0.14022377374757655, + 0.7594456618689025, + -0.0841392471768898, + 0.6296850188887, + 0.1402128765133524, + 0.7594887431031039, + -0.0841542034642044, + 0.6296334242981556, + 0.14020224729137437, + 0.7595328083790652, + -0.08416973728399975, + 0.629580338699005, + 0.14019260124913455, + 0.7595762363557761, + -0.08418453589020208, + 0.6295279871085265, + 0.14018351731795178, + 0.7596206181234569, + -0.08419893914247731, + 0.6294745879257889, + 0.14017417138930013, + 0.7596636482545032, + -0.0842150148721443, + 0.6294225813623338, + 0.14016485601576228, + 0.7597076903641707, + -0.08423095356007455, + 0.6293695770724753, + 0.14015458294152058, + 0.7597513742190355, + -0.08424715073318051, + 0.6293170445976831, + 0.1401439415189454, + 0.7597948241708693, + -0.08426350105603617, + 0.6292646235059232, + 0.14013394006052282, + 0.7598392293175739, + -0.08428098604895734, + 0.6292109716409622, + 0.1401235674229247, + 0.7598832590928034, + -0.08429759725466943, + 0.6291577586259467, + 0.14011374810618746, + 0.7599268440447899, + -0.08431457529358874, + 0.6291050898861997, + 0.14010364011139717, + 0.759970278221959, + -0.0843314223718435, + 0.6290526316100556, + 0.1400934476856213, + 0.760013410138759, + -0.08434671343012615, + 0.6290005907103039, + 0.14008392209272102, + 0.760057158764861, + -0.08436260767164788, + 0.6289477571083902, + 0.14007421127906344, + 0.7601015221576266, + -0.08437912942490501, + 0.6288940641157672, + 0.14006460884573085, + 0.7601457106438371, + -0.08439561034278792, + 0.6288410463612958, + 0.14005291127240083, + 0.7601905471120498, + -0.08441214435844785, + 0.628787108385706, + 0.14004175910860833, + 0.7602345130754139, + -0.08442757766947974, + 0.6287340422622565, + 0.1400320440414099, + 0.7602786243995748, + -0.0844424118580623, + 0.6286807991421869, + 0.14002265941848477, + 0.7603207480369494, + -0.0844575256021862, + 0.6286300947042577, + 0.1400124655372013, + 0.7603630754227043, + -0.08447226336470057, + 0.6285790202677819, + 0.14000301973517262, + 0.7604075678685833, + -0.08448747518895833, + 0.6285254363819015, + 0.13999276083184262, + 0.760451899153817, + -0.08450331695360404, + 0.6284719467627891, + 0.1399825368729328, + 0.7604962789257501, + -0.08451937343943595, + 0.6284183915328193, + 0.13997217736677925, + 0.7605392384837878, + -0.08453508438825656, + 0.6283663046435299, + 0.13996311450737658, + 0.7605834843650338, + -0.08455071885760326, + 0.6283129265623453, + 0.13995286908980492, + 0.7606268182268163, + -0.08456612170412489, + 0.6282607509334188, + 0.13994228557033545, + 0.760667882637052, + -0.08458077119785111, + 0.628211017210272, + 0.13993349607465852, + 0.7607126687760168, + -0.08459796793878312, + 0.6281567620940179, + 0.1399231990052323, + 0.7607564596948619, + -0.08461347073935295, + 0.6281038416416966, + 0.13991330786213008, + 0.7607998980656874, + -0.08462843934605824, + 0.6280514620860974, + 0.13990319270340304, + 0.760843028922119, + -0.0846433221449309, + 0.6279996324266682, + 0.13989229796116276, + 0.7608866869710792, + -0.08465837334106029, + 0.6279469898013756, + 0.13988204821495787, + 0.7609301528372451, + -0.08467428715659177, + 0.6278943562086687, + 0.13987224542028173, + 0.7609734166109786, + -0.0846912932212419, + 0.6278418908179865, + 0.13986208992440838, + 0.7610174532439626, + -0.08470665059949894, + 0.6277889273597826, + 0.13985092737175914, + 0.7610618018647747, + -0.08472146185306113, + 0.6277353325327238, + 0.1398411954105566, + 0.76110592184729, + -0.08473724663961782, + 0.6276819235082233, + 0.13983124708712452, + 0.7611504787686201, + -0.08475329553137717, + 0.6276280342059777, + 0.1398208791476141, + 0.7611934995929817, + -0.08476819713108995, + 0.627576110348193, + 0.1398107100789011, + 0.761237565911565, + -0.08478509596868683, + 0.6275225813734802, + 0.13980080691104932, + 0.7612821556808141, + -0.0848012432329413, + 0.6274684615675058, + 0.1397911239178929, + 0.7613256665952807, + -0.08481625745592873, + 0.6274157231461839, + 0.13978176634802023, + 0.7613685126526119, + -0.08483262109098187, + 0.6273638084958705, + 0.13977147824052083, + 0.7614119304865238, + -0.08484678310356958, + 0.6273113865216344, + 0.13976165371826915, + 0.7614560457205546, + -0.08486275667267962, + 0.6272579252837187, + 0.1397515586113265, + 0.7615002696267205, + -0.0848799448745501, + 0.6272042295106969, + 0.13974114927400075, + 0.7615441862578799, + -0.08489610700066247, + 0.6271510730016633, + 0.13973058013841674, + 0.7615878494020036, + -0.08491196877261313, + 0.6270979081924224, + 0.13972157579657557, + 0.7616310370801717, + -0.08492697438974546, + 0.6270454948991581, + 0.13971227470718312, + 0.7616733602099983, + -0.08494170664359246, + 0.6269942039352423, + 0.13970278111224485, + 0.7617166690696303, + -0.08495704479965854, + 0.6269415527649641, + 0.1396936148040833, + 0.7617600708307936, + -0.0849729811671183, + 0.6268889299532261, + 0.1396834151269795 + ], + "SENSOR_ID": "USGS_LINE_SCANNER", + "SCAN_DURATION": 24.986624, + "ECCENTRICITY": 0.10833914355442961, + "STARTING_EPHEMERIS_TIME": 336952542.7430252, + "STARTING_LINE": 1, + "STARTING_SAMPLE": 0, + "DETECTOR_SAMPLE_ORIGIN": [ + 2543.46099 + ], + "IMAGE_ID": "UNKNOWN", + "PLATFORM": 1, + "TOTAL_LINES": 13312, + "EPHEM_RATES": [ + 577.2106594904789, + 204.6585938234913, + 3381.7717494595136, + 577.6490718683777, + 204.46290095848, + 3381.703978652778, + 578.0874671157152, + 204.2671955269565, + 3381.636141572294, + 578.5258452527404, + 204.07147743736746, + 3381.5682382198147, + 578.9642062205071, + 203.87574687988996, + 3381.5002685972263, + 579.4025500322706, + 203.6800037652969, + 3381.4322327065743, + 579.8408766830288, + 203.4842481000768, + 3381.3641305495617, + 580.2791861832013, + 203.28847979690508, + 3381.295962128272, + 580.7174784803735, + 203.0926990434564, + 3381.2277274443913, + 581.1557535904506, + 202.89690574436497, + 3381.15942649996, + 581.5940115015428, + 202.70109991562816, + 3381.0910592970436, + 582.032252229237, + 202.50528146630182, + 3381.022625837559, + 582.4704757189864, + 202.30945057568647, + 3380.9541261234554, + 582.9086819873155, + 202.1136071647282, + 3380.885560156712, + 583.3468710203196, + 201.9177512343941, + 3380.816927939167, + 583.7850428311, + 201.72188270422515, + 3380.748229473115, + 584.2231973714602, + 201.5260017506168, + 3380.6794647603065, + 584.6613346544793, + 201.33010829461236, + 3380.610633802825, + 585.0994546695724, + 201.13420233829416, + 3380.5417366027896, + 585.5375574077266, + 200.9382838786273, + 3380.472773162133, + 585.9756428822376, + 200.74235284313235, + 3380.4037434831266, + 586.4137110404907, + 200.5464094067354, + 3380.3346475675316, + 586.8517618955855, + 200.35045348724825, + 3380.2654854175335, + 587.289795442691, + 200.15448508654393, + 3380.1962570352034, + 587.7278116876356, + 199.95850412224237, + 3380.1269624227803, + 588.1658105834692, + 199.76251077379513, + 3380.0576015821644, + 588.6037921437057, + 199.56650495843255, + 3379.9881745154094, + 589.0417563542774, + 199.37048668076434, + 3379.9186812247576, + 589.4797032359236, + 199.17445585266557, + 3379.849121712418, + 589.9176327285187, + 198.97841266185637, + 3379.7794959801736, + 590.3555448505076, + 198.78235701906573, + 3379.709804030396, + 590.7934395888426, + 198.58628892968326, + 3379.6400458650783, + 591.2313169619805, + 198.3902083116903, + 3379.5702214864523, + 591.6691769147125, + 198.19411534401698, + 3379.5003308965256, + 592.107019456096, + 197.99800994482857, + 3379.4303740975765, + 592.5448445857488, + 197.80189211234182, + 3379.360351091523, + 592.9826523166355, + 197.60576176744487, + 3379.2902618808494, + 593.4204425857703, + 197.40961909250382, + 3379.2201064673236, + 593.8582154147738, + 197.21346399829764, + 3379.1498848531896, + 594.2959707902504, + 197.01729649559584, + 3379.0795970405884, + 594.7337087322613, + 196.82111649424883, + 3379.009243031785, + 595.1714291829193, + 196.62492417694594, + 3378.9388228286716, + 595.6091321569146, + 196.42871946175143, + 3378.8683364330627, + 596.0468176446909, + 196.23250234438473, + 3378.797783846617, + 596.4844856598066, + 196.03627275652468, + 3378.727165072414, + 596.9221361479282, + 195.8400308660514, + 3378.65648011247, + 597.3597691267452, + 195.64377659617324, + 3378.585728968746, + 597.797384585446, + 195.44750994617328, + 3378.5149116435427, + 598.2349825380064, + 195.25123083182794, + 3378.444028139099, + 598.6725629504792, + 195.05493943391744, + 3378.3730785937155, + 599.1101258271823, + 194.8586356730271, + 3378.302062938083, + 599.5476711461398, + 194.66231954453173, + 3378.2309811057894, + 599.9851989220357, + 194.46599098165797, + 3378.159833098317, + 600.4227091048475, + 194.26965014387946, + 3378.088618916093, + 600.8602017032467, + 194.073296960244, + 3378.017338560343, + 601.297676712209, + 193.87693142944295, + 3377.945992032057, + 601.735134119098, + 193.6805535680265, + 3377.874579333521, + 602.1725739407386, + 193.4841632716085, + 3377.8031004644336, + 602.6099961189133, + 193.28776073859865, + 3377.7315554257766, + 603.0474006744346, + 193.09134587610026, + 3377.6599442186225, + 603.4847875935219, + 192.89491868893643, + 3377.588266844145, + 603.9221568899187, + 192.6984790958747, + 3377.5165233034268, + 604.3595085125908, + 192.502027274406, + 3377.4447135975392, + 604.7968424687797, + 192.3055631478771, + 3377.3728377274747, + 605.2341587571806, + 192.1090867094194, + 3377.3008956946574, + 605.6714573857284, + 191.91259788692273, + 3377.2288875003787, + 606.1087383074959, + 191.71609685161152, + 3377.1568131454, + 606.5460015273816, + 191.5195835250755, + 3377.0846726315417, + 606.9832470425258, + 191.3230579061634, + 3377.012465959811, + 607.4204748625847, + 191.12651991395924, + 3376.9401931316916, + 607.8576849376243, + 190.92996973019683, + 3376.8678541484105, + 608.294877282872, + 190.7334072734051, + 3376.7954490115367, + 608.7320518847243, + 190.53683254312003, + 3376.7229777223997, + 609.1692087565967, + 190.34024545517175, + 3376.6504402826968, + 609.6063478476783, + 190.14364619363218, + 3376.5778366938334, + 610.0434691737495, + 189.9470346734128, + 3376.5051669572867, + 610.4805727212195, + 189.75041089321255, + 3376.432431074881, + 610.9176585053165, + 189.5537747785822, + 3376.3596290483383, + 611.3547264725008, + 189.35712650716414, + 3376.286760879045, + 611.7917766367719, + 189.16046599012316, + 3376.213826569101, + 612.2288089880965, + 188.96379323672662, + 3376.1408261200154, + 612.6658235425102, + 188.7671081608478, + 3376.0677595339666, + 613.1028202444384, + 188.5704109437839, + 3375.9946268124736, + 613.5397991114255, + 188.37370149837002, + 3375.921427957767, + 613.9767601296313, + 188.1769798331043, + 3375.848162971575, + 614.4137033116331, + 187.9802458666635, + 3375.774831856296, + 614.8506286128929, + 187.78349977538846, + 3375.7014346135607, + 615.2875360385173, + 187.58674147240512, + 3375.6279712457135, + 615.7244255827909, + 187.38997096839134, + 3375.554441754839, + 616.161297258985, + 187.1931881746719, + 3375.4808461433354, + 616.5981510159427, + 186.99639327638184, + 3375.4071844131504, + 617.0349868634444, + 186.7995861827493, + 3375.3334565666933, + 617.4718047952935, + 186.60276690245271, + 3375.2596626063178, + 617.9086048027244, + 186.40593544430945, + 3375.185802534423, + 618.3453868986022, + 186.2090917108084, + 3375.1118763533336, + 618.7821510297766, + 186.0122358994108, + 3375.037884065525, + 619.2188972111221, + 185.81536791398108, + 3374.963825673483, + 619.6556254287693, + 185.6184877677498, + 3374.8897011797167, + 620.0923357060415, + 185.42159536460812, + 3374.815510586989, + 620.5290279828295, + 185.22469089637667, + 3374.7412538975404, + 620.9657022736291, + 185.0277742747158, + 3374.6669311141463, + 621.4023585712298, + 184.8308455019415, + 3374.59254223956, + 621.8389968900209, + 184.633904496939, + 3374.5180872764945, + 622.2756171728745, + 184.43695144221033, + 3374.443566227513, + 622.7122194369779, + 184.2399862492025, + 3374.3689790954213, + 623.1488036741925, + 184.04300892512933, + 3374.294325883062, + 623.5853698936473, + 183.8460193880332, + 3374.2196065932226, + 624.0219180481215, + 183.6490178142189, + 3374.144821228684, + 624.4584481475721, + 183.45200411696834, + 3374.0699697922933, + 624.8949601838921, + 183.2549783093732, + 3373.9950522860563, + 625.3314541746387, + 183.05794030381645, + 3373.920068713427, + 625.7679300606012, + 182.86089027664548, + 3373.8450190777453, + 626.204387858478, + 182.66382815111368, + 3373.769903381465, + 626.6408275573316, + 182.4667539246244, + 3373.6947216279373, + 627.0772491754739, + 182.26966751887252, + 3373.6194738202607, + 627.5136526617067, + 182.07256910970898, + 3373.5441599763135, + 627.9500380515422, + 181.87545861046803, + 3373.4687802731473, + 628.3864053096178, + 181.6783360339312, + 3373.393334524477, + 628.8227544506461, + 181.48120129378484, + 3373.3178227322587, + 629.2590854241042, + 181.2840545656971, + 3373.2422448981065, + 629.6953982356672, + 181.08689577439063, + 3373.166601023935, + 630.1316928826777, + 180.8897249144799, + 3373.0908911116885, + 630.5679693559789, + 180.6925419985202, + 3373.0151151634614, + 631.0042276669685, + 180.49534693709919, + 3372.9392731814037, + 631.4404677649992, + 180.29813990901684, + 3372.863365166353, + 631.8766896599473, + 180.10092083996284, + 3372.787391120198, + 632.3128933459951, + 179.90368972712238, + 3372.711351044656, + 632.7490788383408, + 179.70644648908663, + 3372.6352449416945, + 633.1852460800271, + 179.50919130305982, + 3372.559072812732, + 633.6213950841807, + 179.31192408431312, + 3372.4828346597765, + 634.0575258444492, + 179.1146448501652, + 3372.4065304843434, + 634.4936383723938, + 178.91735349814246, + 3372.3301602886045, + 634.9297326191638, + 178.72005022021878, + 3372.2537240737447, + 635.3658085925174, + 178.52273492603322, + 3372.1772218419437, + 635.8018662878935, + 178.32540763123671, + 3372.1006535947354, + 636.2379057181494, + 178.1280682351448, + 3372.024019334179, + 636.6739268240871, + 177.93071693218394, + 3371.9473190616673, + 637.1099296293165, + 177.73335363509347, + 3371.8705527792163, + 637.5459141183384, + 177.5359783425341, + 3371.7937204883974, + 637.9818803044948, + 177.3385909792552, + 3371.7168221913703, + 638.4178281409094, + 177.14119171767078, + 3371.6398578894964, + 638.8537576312003, + 176.94378047925323, + 3371.5628275847494, + 639.2896687755791, + 176.74635726333733, + 3371.4857312788326, + 639.7255615836119, + 176.54892199619852, + 3371.4085689739113, + 640.1614360004975, + 176.35147484750814, + 3371.331340671276, + 640.5972920437162, + 176.15401573944658, + 3371.254046373042, + 641.0331297022057, + 175.9565446725155, + 3371.1766860810067, + 641.4689489881731, + 175.75906156666377, + 3371.0992597970426, + 641.9047498528769, + 175.5615665984001, + 3371.0217675229633, + 642.3405323061376, + 175.36405968367157, + 3370.9442092604627, + 642.7762963385768, + 175.166540834032, + 3370.8665850116677, + 643.2120419690925, + 174.9690099588936, + 3370.788894778465, + 643.6477691380474, + 174.7714672385421, + 3370.71113856256, + 644.0834778604996, + 174.573912593566, + 3370.633316365926, + 644.5191681315882, + 174.37634602166736, + 3370.555428190297, + 644.9548399390159, + 174.17876753737883, + 3370.477474037876, + 645.3904932957133, + 173.98117704795922, + 3370.3994539105256, + 645.8261281498189, + 173.78357473124083, + 3370.3213678101206, + 646.2617445171679, + 173.58596051534064, + 3370.2432157386165, + 646.6973423859777, + 173.38833439529256, + 3370.164997697982, + 647.1329217701602, + 173.19069628945545, + 3370.086713690342, + 647.5684826174994, + 172.9930463796356, + 3370.0083637174166, + 648.0040249425747, + 172.79538458225306, + 3369.929947781446, + 648.4395487336967, + 172.59771090195724, + 3369.851465884168, + 648.8750540042565, + 172.40002525015564, + 3369.7729180280057, + 649.3105407071116, + 172.20232781009094, + 3369.6943042147172, + 649.7460088492486, + 172.00461850019815, + 3369.6156244462454 + ], + "DT_QUAT": 0.14962050299401197, + "FOCAL": [ + 352.9271664 + ], + "DETECTOR_LINE_ORIGIN": [ + 0.430442527 + ], + "MOUNTING_ANGLES": [ + 0, + 0, + 0 + ], + "T0_EPHEM": -12.493312001228333, + "DETECTOR_SAMPLE_SUMMING": 1, + "REFERENCE_HEIGHT": 30, + "ATMREF": 0, + "SENSOR_TYPE": "USGSAstroLineScanner", + "TOTAL_SAMPLES": 5000, + "ABERR": 0, + "OPTICAL_DIST_COEF": [ + -0.0073433925920054505, + 0.000028375878636241697, + 1.2841989124027099e-8 + ], + "COLL_ID": "UNKNOWN", + "DETECTOR_LINE_OFFSET": 0, + "EPHEM_PTS": [ + -3344984.7635569414, + 1414253.3259294357, + 516920.8551554641, + -3344898.0569959953, + 1414284.0427114894, + 517428.6568225932, + -3344811.2846110724, + 1414314.7300682596, + 517936.4483113707, + -3344724.44510066, + 1414345.3884083119, + 518444.2301354102, + -3344637.5410464145, + 1414376.017018244, + 518952.0012460955, + -3344550.5711568166, + 1414406.6162095445, + 519459.7621665537, + -3344463.5354879526, + 1414437.1860332787, + 519967.512835274, + -3344376.4326747633, + 1414467.7267563627, + 520475.25379055354, + -3344289.2653872855, + 1414498.237762719, + 520982.98399355257, + -3344202.0322202053, + 1414528.7194001542, + 521490.7039481079, + -3344114.733294605, + 1414559.1716165838, + 521998.41362575465, + -3344027.367265647, + 1414589.5947565131, + 522506.1135405663, + -3343939.9367110464, + 1414619.9881774536, + 523013.80267957255, + -3343852.44033158, + 1414650.3522257532, + 523521.48154591897, + -3343764.8781580124, + 1414680.6868292266, + 524029.1500985343, + -3343677.248921418, + 1414710.9922926023, + 524536.8088617297, + -3343589.5551588465, + 1414741.2680615005, + 525044.4567654963, + -3343501.795619295, + 1414771.5144391216, + 525552.094357906, + -3343413.970303211, + 1414801.7313948444, + 526059.7215767257, + -3343326.0791587243, + 1414831.9189304726, + 526567.3384713568, + -3343238.1209786353, + 1414862.0773459957, + 527074.9455285893, + -3343150.0982801435, + 1414892.2060245103, + 527582.5416893421, + -3343062.009817717, + 1414922.3052719801, + 528090.1274883918, + -3342973.855586942, + 1414952.3751427094, + 528597.7028539944, + -3342885.6342902053, + 1414982.4158351792, + 529105.2683812495, + -3342797.3485070933, + 1415012.4268156793, + 529612.8229507506, + -3342708.9969350435, + 1415042.4083897478, + 530120.367112215, + -3342620.579608297, + 1415072.3604816117, + 530627.9008497486, + -3342532.0952482126, + 1415102.2835078973, + 531135.4246648523, + -3342443.5464008846, + 1415132.1767368657, + 531642.937497262, + -3342354.931798397, + 1415162.0405537065, + 532150.4398710581, + -3342266.2514073434, + 1415191.8748916087, + 532657.9317985815, + -3342177.5040125665, + 1415221.6801318019, + 533165.4137545103, + -3342088.6921612374, + 1415251.4556232728, + 533672.8846783533, + -3341999.8145645116, + 1415281.2016078795, + 534180.3451053422, + -3341910.8711638735, + 1415310.9182030298, + 534687.7950646742, + -3341821.8608111083, + 1415340.6057152997, + 535195.2349897224, + -3341732.7859741454, + 1415370.2633736928, + 535702.6638579721, + -3341643.6453870772, + 1415399.891605364, + 536210.082194687, + -3341554.4390926897, + 1415429.49034091, + 536717.4899732765, + -3341465.165759162, + 1415459.059985701, + 537224.8877579395, + -3341375.827989956, + 1415488.5998457868, + 537732.2744242979, + -3341286.424491319, + 1415518.1102478516, + 538239.6504980756, + -3341196.955222019, + 1415547.5911843383, + 538747.0160153807, + -3341107.4190330473, + 1415577.042953903, + 539254.3714003059, + -3341017.8183410126, + 1415606.4649208828, + 539761.715705868, + -3340928.1519784383, + 1415635.8574525346, + 540269.0493932187, + -3340838.4199032094, + 1415665.2205199061, + 540776.3724136503, + -3340748.6208164883, + 1415694.5544396045, + 541283.6853287611, + -3340658.7572690323, + 1415723.8585574476, + 541790.9871032314, + -3340568.8280682396, + 1415753.1332122597, + 542298.2781732685, + -3340478.8331265943, + 1415782.3783646405, + 542805.5586124986, + -3340388.7712648236, + 1415811.5943326084, + 543312.8288597232, + -3340298.6449359134, + 1415840.7805517977, + 543820.0879171474, + -3340208.4528982555, + 1415869.9372571341, + 544327.3362839004, + -3340118.195155131, + 1415899.0645035729, + 544834.5739478741, + -3340027.8718059235, + 1415928.162229257, + 545341.8008449583, + -3339937.4814178883, + 1415957.230806338, + 545849.0175759157, + -3339847.0266632913, + 1415986.2695295566, + 546356.2230292057, + -3339756.506196135, + 1416015.278816968, + 546863.417757144, + -3339665.920079152, + 1416044.2586040378, + 547370.6017184281, + -3339575.2669772855, + 1416073.2091953114, + 547877.7754404312, + -3339484.549472209, + 1416102.130005238, + 548384.9378503128, + -3339393.7663423284, + 1416131.021251378, + 548892.0894683693, + -3339302.9174882025, + 1416159.8830442035, + 549399.2303121431, + -3339212.001726886, + 1416188.7156102757, + 549906.3608406477, + -3339121.021578687, + 1416217.518419424, + 550413.4800449265, + -3339029.97577349, + 1416246.2916594862, + 550920.5884098617, + -3338938.8642881378, + 1416275.0354162364, + 551427.6859499345, + -3338847.685871104, + 1416303.749941524, + 551934.7731868586, + -3338756.4430857575, + 1416332.4346587101, + 552441.8490014519, + -3338665.134668933, + 1416361.0899031959, + 552948.9139669661, + -3338573.7605854603, + 1416389.7156031698, + 553455.9680453886, + -3338482.319584477, + 1416418.3120760429, + 553963.0117714985, + -3338390.8142150347, + 1416446.8787211247, + 554470.0440634033, + -3338299.2432389436, + 1416475.4158885696, + 554977.0654437672, + -3338207.6065572756, + 1416503.9235048061, + 555484.0759505755, + -3338115.9030054514, + 1416532.4019045692, + 555991.0760079188, + -3338024.1351173897, + 1416560.850457364, + 556498.0646415318, + -3337932.301579498, + 1416589.269485902, + 557005.0423030207, + -3337840.40241196, + 1416617.6589630425, + 557512.0090042686, + -3337748.4363675932, + 1416646.0192395872, + 558018.96525606, + -3337656.405951001, + 1416674.349652528, + 558525.9100247194, + -3337564.30989921, + 1416702.6505741682, + 559032.8438343277, + -3337472.1482477537, + 1416730.9219273385, + 559539.7666212366, + -3337379.919738127, + 1416759.1640065247, + 560046.6788964581, + -3337287.626883474, + 1416787.3763099718, + 560553.5796536355, + -3337195.268399965, + 1416815.5590309917, + 561060.4693883472, + -3337102.8443276165, + 1416843.7122051166, + 561567.348101548, + -3337010.3533813544, + 1416871.8361440203, + 562074.2162553165, + -3336917.79812152, + 1416899.9302445203, + 562581.0728525709, + -3336825.1772079146, + 1416927.9947651082, + 563087.9184169002, + -3336732.4907587594, + 1416956.029745115, + 563594.752871853, + -3336639.7387086474, + 1416984.0351679132, + 564101.5762337861, + -3336546.919752084, + 1417012.0113494212, + 564608.3890365248, + -3336454.036547826, + 1417039.957649024, + 565115.1901830019, + -3336361.087703108, + 1417067.8744017405, + 565621.9802366958, + -3336268.0733229336, + 1417095.7615264636, + 566128.7591560738, + -3336174.992068628, + 1417123.6194855054, + 566635.5274813409, + -3336081.8465166334, + 1417151.4475368068, + 567142.2841149436, + -3335988.6353862057, + 1417179.2460097212, + 567649.0296289439, + -3335895.3587082895, + 1417207.0149269353, + 568155.763936888, + -3335802.0151694193, + 1417234.7546023158, + 568662.4876017886, + -3335708.6073471727, + 1417262.4643523016, + 569169.1995617322, + -3335615.133932114, + 1417290.1445391916, + 569675.900342447, + -3335521.594996186, + 1417317.7951704876, + 570182.5899049994, + -3335427.9892413868, + 1417345.4164878465, + 570689.2687727432, + -3335334.3191857003, + 1417373.0079493744, + 571195.9358770864, + -3335240.583571107, + 1417400.5698199817, + 571702.5917874939, + -3335146.782418922, + 1417428.1020932898, + 572209.2364322202, + -3335052.914457099, + 1417455.605141949, + 572715.8703234645, + -3334958.982206799, + 1417483.078252926, + 573222.4924727073, + -3334864.9844411477, + 1417510.5217723448, + 573729.103318985, + -3334770.9210956274, + 1417537.9356691819, + 574235.7029238085, + -3334676.791004055, + 1417565.3203233655, + 574742.2916872838, + -3334582.596597201, + 1417592.6750952657, + 575248.8686517256, + -3334488.3366859336, + 1417620.0002393317, + 575755.4343106085, + -3334394.011242155, + 1417647.295771555, + 576261.988630888, + -3334299.6190186613, + 1417674.5620201158, + 576768.5321592239, + -3334205.1625225414, + 1417701.7984021092, + 577275.0638139574, + -3334110.640547868, + 1417729.0051129225, + 577781.5841020863, + -3334016.0530199045, + 1417756.182240697, + 578288.093039739, + -3333921.399972845, + 1417783.329767554, + 578794.5906148057, + -3333826.680169686, + 1417810.4479836978, + 579301.0772984121, + -3333731.896105329, + 1417837.5363021805, + 579807.5520832451, + -3333637.0465651886, + 1417864.5949697618, + 580314.0154907854, + -3333542.1315039084, + 1417891.6240337722, + 580820.467437637, + -3333447.1497151353, + 1417918.6238292258, + 581326.9084821079, + -3333352.10364342, + 1417945.5936753815, + 581833.3376161599, + -3333256.992064066, + 1417972.5338802338, + 582339.7553121058, + -3333161.8150804997, + 1417999.444466233, + 582846.1615082035, + -3333066.5712697012, + 1418026.3257293953, + 583352.5567788554, + -3332971.263257699, + 1418053.1770966537, + 583858.9400654723, + -3332875.889768058, + 1418079.9988055404, + 584365.3118515231, + -3332780.4508246365, + 1418106.7908982267, + 584871.6721645535, + -3332684.945085961, + 1418133.5536930414, + 585378.0214908632, + -3332589.375157767, + 1418160.2864666476, + 585884.3588055966, + -3332493.739778629, + 1418186.9896769337, + 586390.6845622734, + -3332398.0388978496, + 1418213.6632292925, + 586896.9988079255, + -3332302.271313332, + 1418240.3074251225, + 587403.3020160459, + -3332206.4395134356, + 1418266.9217356283, + 587909.5931553309, + -3332110.5422760784, + 1418293.5063267448, + 588415.8727197138, + -3332014.579531965, + 1418320.0613251452, + 588922.1407516841, + -3331918.550130211, + 1418346.5869791135, + 589428.3976967313, + -3331822.4564910396, + 1418373.0826454523, + 589934.6425349349, + -3331726.2974308934, + 1418399.5486895875, + 590440.875776619, + -3331630.072925614, + 1418425.9850809867, + 590947.097396838, + -3331533.781703729, + 1418452.3921027503, + 591453.3078828476, + -3331437.4263142683, + 1418478.7692010142, + 591959.5062494477, + -3331341.0054539647, + 1418505.1166290366, + 592465.693019993, + -3331244.519202849, + 1418531.4343722716, + 592971.8680826226, + -3331147.966248248, + 1418557.7228243996, + 593478.0320001193, + -3331051.3490844257, + 1418583.981260846, + 593984.1837616161, + -3330954.6665273765, + 1418610.2100183694, + 594490.3238151997, + -3330857.9185165763, + 1418636.4091500717, + 594996.4522247536, + -3330761.105115619, + 1418662.5785973235, + 595502.568878644, + -3330664.2250402076, + 1418688.7186700592, + 596008.6743596301, + -3330567.280774377, + 1418714.8287629937, + 596514.7676114627, + -3330470.271132082, + 1418740.9092065508, + 597020.8491207011, + -3330373.1960415533, + 1418766.9599618218, + 597526.9189117998, + -3330276.054291986, + 1418792.9813455888, + 598032.9774330789, + -3330178.8484212114, + 1418818.9727481294, + 598539.0236995697, + -3330081.577136748, + 1418844.934485981, + 599045.0582118208, + -3329984.240444254, + 1418870.866516383, + 599551.0809076005, + -3329886.837091333, + 1418896.7691568853, + 600057.0923694388, + -3329789.369640119, + 1418922.6418641235, + 600563.09146746, + -3329691.8367641326, + 1418948.4848456539, + 601069.078786302 + ], + "CENTER_EPHEMERIS_TIME": 336952555.2363372, + "INT_TIME": 0.001877, + "NUMBER_OF_QUATERNIONS": 167, + "ITRANSS": [ + 0, + 0, + 142.85714285714 + ], + "IKCODE": -74021, + "PLATFORM_ID": "UNKNOWN", + "ISIS_Z_DIRECTION": 1, + "MAX_VALID_HT": 8000, + "TRI_PARAMETERS": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 352.9271664, + 0, + 0 + ], + "TRAJ_ID": "UNKNOWN", + "ITRANSL": [ + 0, + 142.85714285714, + 0 + ], + "REF_DATE_TIME": "UNKNOWN" + }, + "loaded_kernels": null + }, + "success": true +} \ No newline at end of file diff --git a/plio/io/io_json.py b/plio/io/io_json.py index a463e6cf7006c4d71b0ca93e0597e9f8534d6591..161a68e4c0c102f3965753074bd98394b98390d3 100644 --- a/plio/io/io_json.py +++ b/plio/io/io_json.py @@ -1,6 +1,15 @@ import json +import numpy as np +class NumpyEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, np.ndarray): + return obj.tolist() + elif isinstance(obj, datetime.date): + return obj.isoformat() + return json.JSONEncoder.default(self, obj) + def read_json(inputfile): """ Read the input json file into a python dictionary. diff --git a/plio/spatial/footprint.py b/plio/spatial/footprint.py new file mode 100644 index 0000000000000000000000000000000000000000..43ac6490ee4f23bd2358f9928690868345c25456 --- /dev/null +++ b/plio/spatial/footprint.py @@ -0,0 +1,59 @@ +import numpy as np +import pyproj +import ogr + +def generate_gcps(camera, nnodes=5, semi_major=3396190, semi_minor=3376200): + ecef = pyproj.Proj(proj='geocent', a=semi_major, b=semi_minor) + lla = pyproj.Proj(proj='latlon', a=semi_major, b=semi_minor) + + isize = camera.imagesize[::-1] + x = np.linspace(0,isize[1], 10) + y = np.linspace(0,isize[0], 10) + boundary = [(i,0.) for i in x] + [(isize[1], i) for i in y[1:]] +\ + [(i, isize[0]) for i in x[::-1][1:]] + [(0.,i) for i in y[::-1][1:]] + gnds = np.empty((len(boundary), 3)) + for i, b in enumerate(boundary): + gnds[i] = camera.imageToGround(*b, 0) + lons, lats, alts = pyproj.transform(ecef, lla, gnds[:,0], gnds[:,1], gnds[:,2]) + lla = np.vstack((lons, lats, alts)).T + + tr = zip(boundary, lla) + + gcps = [] + for i, t in enumerate(tr): + l = '<GCP Id="{}" Info="{}" Pixel="{}" Line="{}" X="{}" Y="{}" Z="{}" />'.format(i, i, t[0][1], t[0][0], t[1][0], t[1][1], t[1][2]) + gcps.append(l) + + return gcps + +def generate_latlon_footprint(camera, nnodes=5, semi_major=3396190, semi_minor=3376200): + ecef = pyproj.Proj(proj='geocent', a=semi_major, b=semi_minor) + lla = pyproj.Proj(proj='latlon', a=semi_major, b=semi_minor) + + isize = camera.imagesize[::-1] + x = np.linspace(0,isize[1], 10) + y = np.linspace(0,isize[0], 10) + boundary = [(i,0.) for i in x] + [(isize[1], i) for i in y[1:]] +\ + [(i, isize[0]) for i in x[::-1][1:]] + [(0.,i) for i in y[::-1][1:]] + ring = ogr.Geometry(ogr.wkbLinearRing) + for i in boundary: + gnd = camera.imageToGround(*i, 0) + lons, lats, alts = pyproj.transform(ecef, lla, gnd[0], gnd[1], gnd[2]) + ring.AddPoint(lons, lats) + poly = ogr.Geometry(ogr.wkbPolygon) + poly.AddGeometry(ring) + return poly + +def generate_bodyfixed_footprint(camera, nnodes=5): + isize = camera.imagesize[::-1] + x = np.linspace(0,isize[1], 10) + y = np.linspace(0,isize[0], 10) + boundary = [(i,0.) for i in x] + [(isize[1], i) for i in y[1:]] +\ + [(i, isize[0]) for i in x[::-1][1:]] + [(0.,i) for i in y[::-1][1:]] + ring = ogr.Geometry(ogr.wkbLinearRing) + for i in boundary: + gnd = camera.imageToGround(*i, 0) + ring.AddPoint(gnd[0], gnd[1], gnd[2]) + poly = ogr.Geometry(ogr.wkbPolygon) + poly.AddGeometry(ring) + return poly diff --git a/plio/utils/generate_vrt.py b/plio/utils/generate_vrt.py new file mode 100644 index 0000000000000000000000000000000000000000..e58d755d0767cf28fc2817fe373f6a5613204065 --- /dev/null +++ b/plio/utils/generate_vrt.py @@ -0,0 +1,48 @@ +import gdal +import os +import jinja2 +import numpy as np + +from plio.camera.footprint import generate_gcps + +def warped_vrt(camera, raster_size, fpath, outpath=None, no_data_value=0): + gcps = generate_gcps(camera) + xsize, ysize = raster_size + + if outpath is None: + outpath = os.path.dirname(fpath) + outname = os.path.splitext(os.path.basename(fpath))[0] + '.vrt' + outname = os.path.join(outpath, outname) + + xsize, ysize = raster_size + vrt = r'''<VRTDataset rasterXSize="{{ xsize }}" rasterYSize="{{ ysize }}"> + <Metadata/> + <GCPList Projection="{{ proj }}"> + {% for gcp in gcps -%} + {{gcp}} + {% endfor -%} + </GCPList> + <VRTRasterBand dataType="Float32" band="1"> + <NoDataValue>{{ no_data_value }}</NoDataValue> + <Metadata/> + <ColorInterp>Gray</ColorInterp> + <SimpleSource> + <SourceFilename relativeToVRT="0">{{ fpath }}</SourceFilename> + <SourceBand>1</SourceBand> + <SourceProperties rasterXSize="{{ xsize }}" rasterYSize="{{ ysize }}" + DataType="Float32" BlockXSize="512" BlockYSize="512"/> + <SrcRect xOff="0" yOff="0" xSize="{{ xsize }}" ySize="{{ ysize }}"/> + <DstRect xOff="0" yOff="0" xSize="{{ xsize }}" ySize="{{ ysize }}"/> + </SimpleSource> + </VRTRasterBand> + </VRTDataset>''' + + context = {'xsize':xsize, 'ysize':ysize, + 'gcps':gcps, + 'proj':'+proj=longlat +a=3396190 +b=3376200 +no_defs', + 'fpath':fpath, + 'no_data_value':no_data_value} + template = jinja2.Template(vrt) + tmp = template.render(context) + warp_options = gdal.WarpOptions(format='VRT', dstNodata=0) + gdal.Warp(outname, tmp, options=warp_options) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 00d65c765064654255d7a88374175c3ae5a00b2e..da9adbca18b75b353040151dcbd371556ffd4555 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -49,6 +49,7 @@ requirements: - pyproj - cycsm - usgscam + - jinja2 test: imports: