Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Plio
Commits
064ad14c
Commit
064ad14c
authored
6 years ago
by
Adam Paquette
Browse files
Options
Downloads
Patches
Plain Diff
Finalized notebook with annotations and reduced imports.
parent
3d757658
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/Socet2ISIS.ipynb
+82
-201
82 additions, 201 deletions
notebooks/Socet2ISIS.ipynb
with
82 additions
and
201 deletions
notebooks/Socet2ISIS.ipynb
+
82
−
201
View file @
064ad14c
...
...
@@ -8,21 +8,13 @@
"source": [
"import os\n",
"import sys\n",
"import csv\n",
"import pvl\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"import math\n",
"import pyproj\n",
"from functools import singledispatch\n",
"import warnings\n",
"\n",
"from plio.examples import get_path\n",
"from plio.io.io_bae import read_gpf, read_ipf, read_atf\n",
"from plio.io.io_bae import read_gpf, read_ipf, read_atf, save_gpf, save_ipf\n",
"from plio.utils.utils import find_in_dict\n",
"from plio.spatial.transformations import *\n",
"from collections import defaultdict\n",
"from plio.spatial.transformations import apply_isis_transformations, apply_socet_transformations, serial_numbers\n",
"import plio.io.io_controlnetwork as cn\n",
"import plio.io.isis_serial_number as sn"
]
...
...
@@ -33,7 +25,7 @@
"metadata": {},
"outputs": [],
"source": [
"def socet2isis(at_file, cub_file_path,
cub_ipf_map
, target_name, outpath=None):\n",
"def socet2isis(at_file, cub_file_path,
extension
, target_name, outpath=None):\n",
" # Setup the at_file, path to cubes, and control network out path\n",
" at_file = at_file\n",
" cnet_out = os.path.split(os.path.splitext(at_file)[0])[1]\n",
...
...
@@ -43,10 +35,6 @@
" outpath = outpath\n",
" else:\n",
" outpath = os.path.split(at_file)[0]\n",
"\n",
" with open(cub_ipf_map) as cub_ipf_map:\n",
" reader = csv.reader(cub_ipf_map, delimiter = ',')\n",
" image_dict = dict([(row[0], row[1]) for row in reader])\n",
" \n",
" # Read in and setup the atf dict of information\n",
" atf_dict = read_atf(at_file)\n",
...
...
@@ -74,7 +62,7 @@
" socet_df = ipf_df.merge(gpf_df, left_on='pt_id', right_on='point_id')\n",
" \n",
" # Apply the transformations\n",
" apply_transformations(atf_dict, socet_df)\n",
" apply_
socet_
transformations(atf_dict, socet_df)\n",
" \n",
" # Define column remap for socet dataframe\n",
" column_map = {'pt_id': 'id', 'l.': 'y', 's.': 'x',\n",
...
...
@@ -86,30 +74,79 @@
" # Rename the columns using the column remap above\n",
" socet_df.rename(columns = column_map, inplace=True)\n",
" \n",
" # Build an image and serial dict assuming the cubes will be named as the IPFs are\n",
" image_dict = {i: i + extension for i in pd.unique(socet_df['ipf_file'])}\n",
" serial_dict = serial_numbers(image_dict, cub_path)\n",
"\n",
" # creates the control network\n",
" cn.to_isis(os.path.join(outpath, cnet_out + '.net'), socet_df, serial_dict, targetname = targetname)\n",
" return socet_df"
" cn.to_isis(os.path.join(outpath, cnet_out + '.net'), socet_df, serial_dict, targetname = targetname)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled":
tru
e
"scrolled":
fals
e
},
"outputs": [],
"source": [
"# Setup stuffs for the cub information namely the path and extension\n",
"cub_path = '/Volumes/Blueman/'\n",
"targetname = 'Mars'\n",
"cub_map = '/Users/adampaquette/repos/plio/plio/examples/SocetSet/cub_map2.csv'\n",
"def isis2socet(cnet_path, eRadius, eccentricity, cub_path, extension, cub_list, out_gpf, adjusted_flag = False):\n",
" pRadius = eRadius * math.sqrt(1 - (eccentricity ** 2))\n",
" \n",
" df = cn.from_isis(cnet_path)\n",
" # Create cub dict to map ipf to cub\n",
" cub_dict = {i: i + extension for i in cub_list}\n",
"\n",
" # Create serial dict to match serial to ipf\n",
" serial_dict = {sn.generate_serial_number(os.path.join(cub_path, i + extension)): i for i in cub_list}\n",
"\n",
" # Remove duplicate columns\n",
" # There are better ways to do this but pandas was not having it\n",
" columns = []\n",
" column_index = []\n",
"\n",
" for i, column in enumerate(list(df.columns)):\n",
" if column not in columns:\n",
" column_index.append(i)\n",
" columns.append(column)\n",
"\n",
" df = df.iloc[:, column_index]\n",
"\n",
" # Begin translation\n",
" # Remap the ISIS columns to socet column names\n",
" column_map = {'id': 'pt_id', 'line': 'l.', 'sample': 's.', \n",
" 'lineResidual': 'res_l', 'sampleResidual': 'res_s', 'type': 'known', \n",
" 'aprioriLatitudeSigma': 'sig0', 'aprioriLongitudeSigma': 'sig1', 'aprioriRadiusSigma': 'sig2', \n",
" 'linesigma': 'sig_l', 'samplesigma': 'sig_s', 'ignore': 'stat'}\n",
"\n",
" # Depending on the adjusted flag, set the renames for columns appropriately\n",
" if adjusted_flag:\n",
" column_map['adjustedY'] = 'lat_Y_North'\n",
" column_map['adjustedX'] = 'long_X_East'\n",
" column_map['adjustedZ'] = 'ht'\n",
" else:\n",
" column_map['aprioriY'] = 'lat_Y_North'\n",
" column_map['aprioriX'] = 'long_X_East'\n",
" column_map['aprioriZ'] = 'ht'\n",
"\n",
"# Path to atf file\n",
"atf_file = ('/Users/adampaquette/repos/plio/plio/examples/SocetSet/Relative.atf')\n",
" df.rename(columns = column_map, inplace=True)\n",
" \n",
" apply_isis_transformations(df, eRadius, pRadius, serial_dict, extension, cub_path)\n",
"\n",
" # Save the ipf\n",
" save_ipf(df, os.path.split(out_gpf)[0])\n",
"\n",
"socet_df = socet2isis(atf_file, cub_path, cub_map, targetname)"
" # Get the first record from each group as there all the same, put them\n",
" # into a list, and sort it\n",
" points = [int(i[1].index[0]) for i in df.groupby('pt_id')]\n",
" points.sort()\n",
"\n",
" # Set the gpf_df to only the values we need and do a small rename\n",
" gpf_df = df.iloc[points].copy()\n",
" gpf_df.rename(columns = {'pt_id': 'point_id'}, inplace=True)\n",
"\n",
" # Save the gpf\n",
" save_gpf(gpf_df, out_gpf)"
]
},
{
...
...
@@ -118,202 +155,46 @@
"metadata": {},
"outputs": [],
"source": [
"def reverse_known(record):\n",
" \"\"\"\n",
" Converts the known field from a socet dataframe into the\n",
" isis point_type column\n",
"\n",
" Parameters\n",
" ----------\n",
" record : object\n",
" Pandas series object\n",
"\n",
" Returns\n",
" -------\n",
" : str\n",
" String representation of a known field\n",
" \"\"\"\n",
" record_type = record['known']\n",
" if record_type == 0 or record_type == 2:\n",
" return 0\n",
"\n",
" elif record_type == 1 or record_type == 3 or record_type == 4:\n",
" return 3\n",
" \n",
"def lat_socet_coord(record, semi_major, semi_minor):\n",
" \"\"\"\n",
" Function to convert lat_Y_North to ISIS_lat\n",
"\n",
" Parameters\n",
" ----------\n",
" record : object\n",
" Pandas series object\n",
"\n",
" semi_major : float\n",
" Radius from the center of the body to the equater\n",
"\n",
" semi_minor : float\n",
" Radius from the pole to the center of mass\n",
"\n",
" Returns\n",
" -------\n",
" coord_360 : float\n",
" Converted latitude into ocentric space, and mapped\n",
" into 0 to 360\n",
" \"\"\"\n",
" ographic_coord = oc2og(record['lat_Y_North'], semi_major, semi_minor)\n",
" return ((ographic_coord + 180) % 360) - 180\n",
"\n",
"def lon_socet_coord(record, semi_major, semi_minor):\n",
" \"\"\"\n",
" Function to convert lat_Y_North to ISIS_lat\n",
"\n",
" Parameters\n",
" ----------\n",
" record : object\n",
" Pandas series object\n",
"\n",
" semi_major : float\n",
" Radius from the center of the body to the equater\n",
"\n",
" semi_minor : float\n",
" Radius from the pole to the center of mass\n",
"\n",
" Returns\n",
" -------\n",
" coord_360 : float\n",
" Converted latitude into ocentric space, and mapped\n",
" into 0 to 360\n",
" \"\"\"\n",
" ographic_coord = oc2og(record['long_X_East'], semi_major, semi_minor)\n",
" return ((ographic_coord + 180) % 360) - 180\n",
"# Setup stuffs for the cub information namely the path and extension\n",
"cub_path = '/Path/to/cubs'\n",
"\n",
"def fix_sample_line(record, serial_dict, extension, cub_path):\n",
" # Cube location to load\n",
" cube = pvl.load(os.path.join(cub_path, serial_dict[record['serialnumber']] + extension))\n",
" line_size = find_in_dict(cube, 'Lines')\n",
" sample_size = find_in_dict(cube, 'Samples')\n",
"# Name of the target body\n",
"targetname = 'Mars'\n",
"extension = 'cub.-->extension<--'\n",
"\n",
" new_line = record['l.'] - (int(line_size)/2.0) - 1\n",
" new_sample = record['s.'] - (int(sample_size)/2.0) - 1\n",
" return new_line, new_sample\n",
"# Path to atf file\n",
"atf_file = 'Path/to/socket/set/at_file.atf'\n",
"\n",
"def ignore_toggle(record):\n",
" if record['stat'] == True:\n",
" return 0\n",
" else:\n",
" return 1"
"socet2isis(atf_file, cub_path, extension, targetname)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"return_df = cn.from_isis(\"/Users/adampaquette/repos/plio/plio/examples/SocetSet/Relative.net\")\n",
"# Setup stuffs for the cub information namely the path and extension\n",
"# along with eRadius and eccentricity\n",
"cnet = \"Path/to/control/network.net\"\n",
"\n",
"eRadius = 3.39619000000000e+006\n",
"
pRadius = eRadius * (1 -
1.08339143554195e-001
)
\n",
"
eccentricity =
1.08339143554195e-001\n",
"\n",
"adjusted_flag = False\n",
"cub_path = 'Path/to/cubs'\n",
"extension = 'cub.-->extension<--'\n",
"\n",
"cub_path = '/Volumes/Blueman/'\n",
"extension = '.8bit.cub'\n",
"# List of cubes to use\n",
"cub_list = ['D06_029601_1846_XN_04N224W', \n",
" 'F05_037684_1857_XN_05N224W']\n",
"\n",
"# \n",
"cub_dict = {i: i + extension for i in cub_list}\n",
"serial_dict = {sn.generate_serial_number(os.path.join(cub_path, i + extension)): i for i in cub_list}\n",
"\n",
"columns = []\n",
"column_index = []\n",
"\n",
"for i, column in enumerate(list(return_df.columns)):\n",
" if column not in columns:\n",
" column_index.append(i)\n",
" columns.append(column)\n",
"out_gpf = \"/Users/adampaquette/Desktop/InSightE09_XW.gpf\"\n",
"\n",
"return_df = return_df.iloc[:, column_index]\n",
"\n",
"column_map = {'id': 'pt_id', 'line': 'l.', 'sample': 's.', \n",
" 'lineResidual': 'res_l', 'sampleResidual': 'res_s', 'type': 'known', \n",
" 'aprioriLatitudeSigma': 'sig0', 'aprioriLongitudeSigma': 'sig1', 'aprioriRadiusSigma': 'sig2', \n",
" 'linesigma': 'sig_l', 'samplesigma': 'sig_s', 'ignore': 'stat'}\n",
"\n",
"if adjusted_flag:\n",
" column_map['adjustedY'] = 'lat_Y_North'\n",
" column_map['adjustedX'] = 'long_X_East'\n",
" column_map['adjustedZ'] = 'ht'\n",
"else:\n",
" column_map['aprioriY'] = 'lat_Y_North'\n",
" column_map['aprioriX'] = 'long_X_East'\n",
" column_map['aprioriZ'] = 'ht'\n",
"\n",
"return_df.rename(columns = column_map, inplace=True)\n",
"\n",
"return_df['known'] = return_df.apply(reverse_known, axis = 1)\n",
"return_df['ipf_file'] = return_df['serialnumber'].apply(lambda serial_number: serial_dict[serial_number])\n",
"return_df['l.'], return_df['s.'] = zip(*return_df.apply(fix_sample_line, serial_dict = serial_dict, \n",
" extension = extension, \n",
" cub_path = cub_path, axis = 1))\n",
"\n",
"ecef = np.array([[return_df['long_X_East']], [return_df['lat_Y_North']], [return_df['ht']]])\n",
"lla = body_fix(ecef, semi_major = eRadius, semi_minor = pRadius, inverse=True)\n",
"return_df['long_X_East'], return_df['lat_Y_North'], return_df['ht'] = lla[0][0], lla[1][0], lla[2][0]\n",
"\n",
"return_df['lat_Y_North'] = return_df.apply(lat_socet_coord, semi_major=eRadius, semi_minor=pRadius, axis = 1)\n",
"return_df['long_X_East'] = return_df.apply(lon_socet_coord, semi_major=eRadius, semi_minor=pRadius, axis = 1)\n",
"\n",
"return_df['stat'] = return_df.apply(ignore_toggle, axis = 1)\n",
"return_df['val'] = return_df['stat']\n",
"\n",
"# Add dumby\n",
"x_dummy = lambda x: np.full(len(return_df), x)\n",
"\n",
"return_df['sig0'] = x_dummy(0)\n",
"return_df['sig1'] = x_dummy(0)\n",
"return_df['sig2'] = x_dummy(0)\n",
"\n",
"return_df['res0'] = x_dummy(0)\n",
"return_df['res1'] = x_dummy(0)\n",
"return_df['res2'] = x_dummy(0)\n",
"\n",
"return_df['fid_x'] = x_dummy(0)\n",
"return_df['fid_y'] = x_dummy(0)\n",
"adjusted_flag = False\n",
"\n",
"return_df['no_obs'] = x_dummy(1)\n",
"return_df['fid_val'] = x_dummy(0)"
"isis2socet(cnet, eRadius, eccentricity, cub_path, extension, cub_list, out_gpf, adjusted_flag)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"return_df[['long_X_East', 'lat_Y_North', 'ht']].iloc[2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"return_df[['long_X_East', 'lat_Y_North', 'ht']].iloc[2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
%% Cell type:code id: tags:
```
python
import
os
import
sys
import
csv
import
pvl
import
pandas
as
pd
import
numpy
as
np
import
math
import
pyproj
from
functools
import
singledispatch
import
warnings
from
plio.examples
import
get_path
from
plio.io.io_bae
import
read_gpf
,
read_ipf
,
read_atf
from
plio.io.io_bae
import
read_gpf
,
read_ipf
,
read_atf
,
save_gpf
,
save_ipf
from
plio.utils.utils
import
find_in_dict
from
plio.spatial.transformations
import
*
from
collections
import
defaultdict
from
plio.spatial.transformations
import
apply_isis_transformations
,
apply_socet_transformations
,
serial_numbers
import
plio.io.io_controlnetwork
as
cn
import
plio.io.isis_serial_number
as
sn
```
%% Cell type:code id: tags:
```
python
def
socet2isis
(
at_file
,
cub_file_path
,
cub_ipf_map
,
target_name
,
outpath
=
None
):
def
socet2isis
(
at_file
,
cub_file_path
,
extension
,
target_name
,
outpath
=
None
):
# Setup the at_file, path to cubes, and control network out path
at_file
=
at_file
cnet_out
=
os
.
path
.
split
(
os
.
path
.
splitext
(
at_file
)[
0
])[
1
]
cub_path
=
cub_file_path
if
(
outpath
):
outpath
=
outpath
else
:
outpath
=
os
.
path
.
split
(
at_file
)[
0
]
with
open
(
cub_ipf_map
)
as
cub_ipf_map
:
reader
=
csv
.
reader
(
cub_ipf_map
,
delimiter
=
'
,
'
)
image_dict
=
dict
([(
row
[
0
],
row
[
1
])
for
row
in
reader
])
# Read in and setup the atf dict of information
atf_dict
=
read_atf
(
at_file
)
# Get the gpf and ipf files using atf dict
gpf_file
=
os
.
path
.
join
(
atf_dict
[
'
PATH
'
],
atf_dict
[
'
GP_FILE
'
]);
ipf_list
=
[
os
.
path
.
join
(
atf_dict
[
'
PATH
'
],
i
)
for
i
in
atf_dict
[
'
IMAGE_IPF
'
]]
# Read in the gpf file and ipf file(s) into seperate dataframes
gpf_df
=
read_gpf
(
gpf_file
)
ipf_df
=
read_ipf
(
ipf_list
)
# Check for differences between point ids using each dataframes
# point ids as a reference
gpf_pt_idx
=
pd
.
Index
(
pd
.
unique
(
gpf_df
[
'
point_id
'
]))
ipf_pt_idx
=
pd
.
Index
(
pd
.
unique
(
ipf_df
[
'
pt_id
'
]))
point_diff
=
ipf_pt_idx
.
difference
(
gpf_pt_idx
)
if
len
(
point_diff
)
!=
0
:
warnings
.
warn
(
"
The following points found in ipf files missing from gpf file:
\n\n
{}.
\
\n\n
Continuing, but these points will be missing from the control network
"
.
format
(
list
(
point_diff
)))
# Merge the two dataframes on their point id columns
socet_df
=
ipf_df
.
merge
(
gpf_df
,
left_on
=
'
pt_id
'
,
right_on
=
'
point_id
'
)
# Apply the transformations
apply_transformations
(
atf_dict
,
socet_df
)
apply_
socet_
transformations
(
atf_dict
,
socet_df
)
# Define column remap for socet dataframe
column_map
=
{
'
pt_id
'
:
'
id
'
,
'
l.
'
:
'
y
'
,
'
s.
'
:
'
x
'
,
'
res_l
'
:
'
lineResidual
'
,
'
res_s
'
:
'
sampleResidual
'
,
'
known
'
:
'
Type
'
,
'
lat_Y_North
'
:
'
aprioriY
'
,
'
long_X_East
'
:
'
aprioriX
'
,
'
ht
'
:
'
aprioriZ
'
,
'
sig0
'
:
'
aprioriLatitudeSigma
'
,
'
sig1
'
:
'
aprioriLongitudeSigma
'
,
'
sig2
'
:
'
aprioriRadiusSigma
'
,
'
sig_l
'
:
'
linesigma
'
,
'
sig_s
'
:
'
samplesigma
'
}
# Rename the columns using the column remap above
socet_df
.
rename
(
columns
=
column_map
,
inplace
=
True
)
# Build an image and serial dict assuming the cubes will be named as the IPFs are
image_dict
=
{
i
:
i
+
extension
for
i
in
pd
.
unique
(
socet_df
[
'
ipf_file
'
])}
serial_dict
=
serial_numbers
(
image_dict
,
cub_path
)
# creates the control network
cn
.
to_isis
(
os
.
path
.
join
(
outpath
,
cnet_out
+
'
.net
'
),
socet_df
,
serial_dict
,
targetname
=
targetname
)
return
socet_df
```
%% Cell type:code id: tags:
```
python
# Setup stuffs for the cub information namely the path and extension
cub_path
=
'
/Volumes/Blueman/
'
targetname
=
'
Mars
'
cub_map
=
'
/Users/adampaquette/repos/plio/plio/examples/SocetSet/cub_map2.csv
'
def
isis2socet
(
cnet_path
,
eRadius
,
eccentricity
,
cub_path
,
extension
,
cub_list
,
out_gpf
,
adjusted_flag
=
False
):
pRadius
=
eRadius
*
math
.
sqrt
(
1
-
(
eccentricity
**
2
))
# Path to atf file
atf_file
=
(
'
/Users/adampaquette/repos/plio/plio/examples/SocetSet/Relative.atf
'
)
df
=
cn
.
from_isis
(
cnet_path
)
# Create cub dict to map ipf to cub
cub_dict
=
{
i
:
i
+
extension
for
i
in
cub_list
}
# Create serial dict to match serial to ipf
serial_dict
=
{
sn
.
generate_serial_number
(
os
.
path
.
join
(
cub_path
,
i
+
extension
)):
i
for
i
in
cub_list
}
# Remove duplicate columns
# There are better ways to do this but pandas was not having it
columns
=
[]
column_index
=
[]
for
i
,
column
in
enumerate
(
list
(
df
.
columns
)):
if
column
not
in
columns
:
column_index
.
append
(
i
)
columns
.
append
(
column
)
df
=
df
.
iloc
[:,
column_index
]
# Begin translation
# Remap the ISIS columns to socet column names
column_map
=
{
'
id
'
:
'
pt_id
'
,
'
line
'
:
'
l.
'
,
'
sample
'
:
'
s.
'
,
'
lineResidual
'
:
'
res_l
'
,
'
sampleResidual
'
:
'
res_s
'
,
'
type
'
:
'
known
'
,
'
aprioriLatitudeSigma
'
:
'
sig0
'
,
'
aprioriLongitudeSigma
'
:
'
sig1
'
,
'
aprioriRadiusSigma
'
:
'
sig2
'
,
'
linesigma
'
:
'
sig_l
'
,
'
samplesigma
'
:
'
sig_s
'
,
'
ignore
'
:
'
stat
'
}
# Depending on the adjusted flag, set the renames for columns appropriately
if
adjusted_flag
:
column_map
[
'
adjustedY
'
]
=
'
lat_Y_North
'
column_map
[
'
adjustedX
'
]
=
'
long_X_East
'
column_map
[
'
adjustedZ
'
]
=
'
ht
'
else
:
column_map
[
'
aprioriY
'
]
=
'
lat_Y_North
'
column_map
[
'
aprioriX
'
]
=
'
long_X_East
'
column_map
[
'
aprioriZ
'
]
=
'
ht
'
socet_df
=
socet2isis
(
atf_file
,
cub_path
,
cub_map
,
targetname
)
```
df
.
rename
(
columns
=
column_map
,
inplace
=
True
)
%% Cell type:code id: tags:
apply_isis_transformations
(
df
,
eRadius
,
pRadius
,
serial_dict
,
extension
,
cub_path
)
```
python
def
reverse_known
(
record
):
"""
Converts the known field from a socet dataframe into the
isis point_type column
Parameters
----------
record : object
Pandas series object
Returns
-------
: str
String representation of a known field
"""
record_type
=
record
[
'
known
'
]
if
record_type
==
0
or
record_type
==
2
:
return
0
elif
record_type
==
1
or
record_type
==
3
or
record_type
==
4
:
return
3
def
lat_socet_coord
(
record
,
semi_major
,
semi_minor
):
"""
Function to convert lat_Y_North to ISIS_lat
Parameters
----------
record : object
Pandas series object
semi_major : float
Radius from the center of the body to the equater
semi_minor : float
Radius from the pole to the center of mass
Returns
-------
coord_360 : float
Converted latitude into ocentric space, and mapped
into 0 to 360
"""
ographic_coord
=
oc2og
(
record
[
'
lat_Y_North
'
],
semi_major
,
semi_minor
)
return
((
ographic_coord
+
180
)
%
360
)
-
180
def
lon_socet_coord
(
record
,
semi_major
,
semi_minor
):
"""
Function to convert lat_Y_North to ISIS_lat
Parameters
----------
record : object
Pandas series object
semi_major : float
Radius from the center of the body to the equater
semi_minor : float
Radius from the pole to the center of mass
Returns
-------
coord_360 : float
Converted latitude into ocentric space, and mapped
into 0 to 360
"""
ographic_coord
=
oc2og
(
record
[
'
long_X_East
'
],
semi_major
,
semi_minor
)
return
((
ographic_coord
+
180
)
%
360
)
-
180
def
fix_sample_line
(
record
,
serial_dict
,
extension
,
cub_path
):
# Cube location to load
cube
=
pvl
.
load
(
os
.
path
.
join
(
cub_path
,
serial_dict
[
record
[
'
serialnumber
'
]]
+
extension
))
line_size
=
find_in_dict
(
cube
,
'
Lines
'
)
sample_size
=
find_in_dict
(
cube
,
'
Samples
'
)
new_line
=
record
[
'
l.
'
]
-
(
int
(
line_size
)
/
2.0
)
-
1
new_sample
=
record
[
'
s.
'
]
-
(
int
(
sample_size
)
/
2.0
)
-
1
return
new_line
,
new_sample
def
ignore_toggle
(
record
):
if
record
[
'
stat
'
]
==
True
:
return
0
else
:
return
1
```
# Save the ipf
save_ipf
(
df
,
os
.
path
.
split
(
out_gpf
)[
0
])
%% Cell type:code id: tags:
# Get the first record from each group as there all the same, put them
# into a list, and sort it
points
=
[
int
(
i
[
1
].
index
[
0
])
for
i
in
df
.
groupby
(
'
pt_id
'
)]
points
.
sort
()
```
python
return_df
=
cn
.
from_isis
(
"
/Users/adampaquette/repos/plio/plio/examples/SocetSet/Relative.net
"
)
# Set the gpf_df to only the values we need and do a small rename
gpf_df
=
df
.
iloc
[
points
].
copy
()
gpf_df
.
rename
(
columns
=
{
'
pt_id
'
:
'
point_id
'
},
inplace
=
True
)
eRadius
=
3.39619000000000e+006
pRadius
=
eRadius
*
(
1
-
1.08339143554195e-001
)
# Save the gpf
save_gpf
(
gpf_df
,
out_gpf
)
```
adjusted_flag
=
False
%% Cell type:code id: tags:
cub_path
=
'
/Volumes/Blueman/
'
extension
=
'
.8bit.cub
'
cub_list
=
[
'
D06_029601_1846_XN_04N224W
'
,
'
F05_037684_1857_XN_05N224W
'
]
```
python
# Setup stuffs for the cub information namely the path and extension
cub_path
=
'
/Path/to/cubs
'
#
cub_dict
=
{
i
:
i
+
extension
for
i
in
cub_list
}
serial_dict
=
{
sn
.
generate_serial_number
(
os
.
path
.
join
(
cub_path
,
i
+
extension
)):
i
for
i
in
cub_list
}
columns
=
[]
column_index
=
[]
for
i
,
column
in
enumerate
(
list
(
return_df
.
columns
)):
if
column
not
in
columns
:
column_index
.
append
(
i
)
columns
.
append
(
column
)
return_df
=
return_df
.
iloc
[:,
column_index
]
column_map
=
{
'
id
'
:
'
pt_id
'
,
'
line
'
:
'
l.
'
,
'
sample
'
:
'
s.
'
,
'
lineResidual
'
:
'
res_l
'
,
'
sampleResidual
'
:
'
res_s
'
,
'
type
'
:
'
known
'
,
'
aprioriLatitudeSigma
'
:
'
sig0
'
,
'
aprioriLongitudeSigma
'
:
'
sig1
'
,
'
aprioriRadiusSigma
'
:
'
sig2
'
,
'
linesigma
'
:
'
sig_l
'
,
'
samplesigma
'
:
'
sig_s
'
,
'
ignore
'
:
'
stat
'
}
if
adjusted_flag
:
column_map
[
'
adjustedY
'
]
=
'
lat_Y_North
'
column_map
[
'
adjustedX
'
]
=
'
long_X_East
'
column_map
[
'
adjustedZ
'
]
=
'
ht
'
else
:
column_map
[
'
aprioriY
'
]
=
'
lat_Y_North
'
column_map
[
'
aprioriX
'
]
=
'
long_X_East
'
column_map
[
'
aprioriZ
'
]
=
'
ht
'
return_df
.
rename
(
columns
=
column_map
,
inplace
=
True
)
return_df
[
'
known
'
]
=
return_df
.
apply
(
reverse_known
,
axis
=
1
)
return_df
[
'
ipf_file
'
]
=
return_df
[
'
serialnumber
'
].
apply
(
lambda
serial_number
:
serial_dict
[
serial_number
])
return_df
[
'
l.
'
],
return_df
[
'
s.
'
]
=
zip
(
*
return_df
.
apply
(
fix_sample_line
,
serial_dict
=
serial_dict
,
extension
=
extension
,
cub_path
=
cub_path
,
axis
=
1
))
ecef
=
np
.
array
([[
return_df
[
'
long_X_East
'
]],
[
return_df
[
'
lat_Y_North
'
]],
[
return_df
[
'
ht
'
]]])
lla
=
body_fix
(
ecef
,
semi_major
=
eRadius
,
semi_minor
=
pRadius
,
inverse
=
True
)
return_df
[
'
long_X_East
'
],
return_df
[
'
lat_Y_North
'
],
return_df
[
'
ht
'
]
=
lla
[
0
][
0
],
lla
[
1
][
0
],
lla
[
2
][
0
]
return_df
[
'
lat_Y_North
'
]
=
return_df
.
apply
(
lat_socet_coord
,
semi_major
=
eRadius
,
semi_minor
=
pRadius
,
axis
=
1
)
return_df
[
'
long_X_East
'
]
=
return_df
.
apply
(
lon_socet_coord
,
semi_major
=
eRadius
,
semi_minor
=
pRadius
,
axis
=
1
)
return_df
[
'
stat
'
]
=
return_df
.
apply
(
ignore_toggle
,
axis
=
1
)
return_df
[
'
val
'
]
=
return_df
[
'
stat
'
]
# Add dumby
x_dummy
=
lambda
x
:
np
.
full
(
len
(
return_df
),
x
)
return_df
[
'
sig0
'
]
=
x_dummy
(
0
)
return_df
[
'
sig1
'
]
=
x_dummy
(
0
)
return_df
[
'
sig2
'
]
=
x_dummy
(
0
)
return_df
[
'
res0
'
]
=
x_dummy
(
0
)
return_df
[
'
res1
'
]
=
x_dummy
(
0
)
return_df
[
'
res2
'
]
=
x_dummy
(
0
)
# Name of the target body
targetname
=
'
Mars
'
extension
=
'
cub.-->extension<--
'
return_df
[
'
fid_x
'
]
=
x_dummy
(
0
)
return_df
[
'
fid_y
'
]
=
x_dummy
(
0
)
# Path to atf file
atf_file
=
'
Path/to/socket/set/at_file.atf
'
return_df
[
'
no_obs
'
]
=
x_dummy
(
1
)
return_df
[
'
fid_val
'
]
=
x_dummy
(
0
)
socet2isis
(
atf_file
,
cub_path
,
extension
,
targetname
)
```
%% Cell type:code id: tags:
```
python
return_df
[[
'
long_X_East
'
,
'
lat_Y_North
'
,
'
ht
'
]].
iloc
[
2
]
```
# Setup stuffs for the cub information namely the path and extension
# along with eRadius and eccentricity
cnet
=
"
Path/to/control/network.net
"
%% Cell type:code id: tags:
eRadius
=
3.39619000000000e+006
eccentricity
=
1.08339143554195e-001
```
python
return_df
[[
'
long_X_East
'
,
'
lat_Y_North
'
,
'
ht
'
]].
iloc
[
2
]
```
cub_path
=
'
Path/to/cubs
'
extension
=
'
cub.-->extension<--
'
%% Cell type:code id: tags:
# List of cubes to use
cub_list
=
[
'
D06_029601_1846_XN_04N224W
'
,
'
F05_037684_1857_XN_05N224W
'
]
```
python
out_gpf
=
"
/Users/adampaquette/Desktop/InSightE09_XW.gpf
"
adjusted_flag
=
False
isis2socet
(
cnet
,
eRadius
,
eccentricity
,
cub_path
,
extension
,
cub_list
,
out_gpf
,
adjusted_flag
)
```
%% Cell type:code id: tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment