Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up cropping notebooks #4211

Merged
merged 2 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 93 additions & 113 deletions isis/notebooks/crop_chandrayaan.ipynb

Large diffs are not rendered by default.

174 changes: 14 additions & 160 deletions isis/notebooks/crop_crism.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pvl\n",
Expand All @@ -30,7 +32,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"header = pvl.load(crism_file)"
Expand Down Expand Up @@ -146,11 +150,12 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"with open(crism_file, 'rb') as f:\n",
" # If detached label, \"^IMAGE\" will be a list.\n",
" image_file = os.path.dirname(crism_file) + \"/\" + header[\"^IMAGE\"].lower()\n",
" with open(image_file, 'rb') as im_f:\n",
" b_image_data = im_f.read()"
Expand All @@ -171,7 +176,9 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"image_data = []\n",
Expand Down Expand Up @@ -212,7 +219,7 @@
}
],
"source": [
"plt.imshow(image_data, cmap='magma')"
"plt.imshow(image_data)"
]
},
{
Expand All @@ -234,23 +241,6 @@
"header['FILE_RECORDS'] = n_lines -1\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"class RealIsisCubeLabelEncoder(pvl.encoder.ISISEncoder): \n",
" def encode_time(self, value):\n",
" if value.microsecond:\n",
" second = u'%02d.%06d' % (value.second, value.microsecond)\n",
" else:\n",
" second = u'%02d' % value.second\n",
"\n",
" time = u'%02d:%02d:%s' % (value.hour, value.minute, second)\n",
" return time"
]
},
{
"cell_type": "code",
"execution_count": 11,
Expand All @@ -273,7 +263,7 @@
"\n",
"grammar = pvl.grammar.ISISGrammar()\n",
"grammar.comments+=((\"#\", \"\\n\"), )\n",
"encoder = RealIsisCubeLabelEncoder()\n",
"encoder = pvl.encoder.ISISEncoder()\n",
"pvl.dump(header, out_label, encoder=encoder, grammar=grammar)"
]
},
Expand All @@ -290,142 +280,6 @@
" f.seek(0, 2)\n",
" f.write(b_reduced_image_data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"header = pvl.load(out_label)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PVLModule([\n",
" ('PDS_VERSION_ID', 'PDS3')\n",
" ('RECORD_TYPE', 'FIXED_LENGTH')\n",
" ('RECORD_BYTES', 3920)\n",
" ('FILE_RECORDS', 9)\n",
" ('LABEL_REVISION_NOTE',\n",
" '2003-11-19, S. Slavney (GEO); 2005-09-25, S. Murchie (JHU/APL); 2007-03-09, '\n",
" 'E. Malaret (ACT Corp.); 2007-09-14, C. Hash (ACT Corp)')\n",
" ('^IMAGE', 't1865_mrrde_70n185_0256_1_cropped.img')\n",
" ('DATA_SET_ID', 'MRO-M-CRISM-5-RDR-MULTISPECTRAL-V1.0')\n",
" ('PRODUCT_ID', 'T1865_MRRDE_70N185_0256_1')\n",
" ('INSTRUMENT_HOST_NAME', 'MARS RECONNAISSANCE ORBITER')\n",
" ('SPACECRAFT_ID', 'MRO')\n",
" ('INSTRUMENT_NAME', 'COMPACT RECONNAISSANCE IMAGING SPECTROMETER FOR MARS')\n",
" ('INSTRUMENT_ID', 'CRISM')\n",
" ('TARGET_NAME', 'MARS')\n",
" ('PRODUCT_TYPE', 'MAP_PROJECTED_MULTISPECTRAL_RDR')\n",
" ('PRODUCT_CREATION_TIME',\n",
" datetime.datetime(2007, 12, 22, 16, 50, 47, 432000, tzinfo=datetime.timezone.utc))\n",
" ('START_TIME', 'N/A')\n",
" ('STOP_TIME', 'N/A')\n",
" ('SPACECRAFT_CLOCK_START_COUNT', 'N/A')\n",
" ('SPACECRAFT_CLOCK_STOP_COUNT', 'N/A')\n",
" ('PRODUCT_VERSION_ID', '1')\n",
" ('PRODUCER_INSTITUTION_NAME', 'APPLIED PHYSICS LABORATORY')\n",
" ('SOFTWARE_NAME', 'PIPE_create_crism_mrdr_product')\n",
" ('SOFTWARE_VERSION_ID', '12.21.07')\n",
" ('MRO:WAVELENGTH_FILE_NAME', 'T1865_MRRWV_70N185_0256_1.TAB')\n",
" ('IMAGE',\n",
" {'BANDS': 1,\n",
" 'BAND_NAME': ['Solar longitude, deg',\n",
" 'Solar distance, AU',\n",
" 'Observation ID, VNIR',\n",
" 'Observation ID, IR',\n",
" 'Ordinal counter, VNIR',\n",
" 'Ordinal counter, IR',\n",
" 'Column number, VNIR',\n",
" 'Column number, IR',\n",
" 'Line, or frame number, VNIR',\n",
" 'Line, or frame number, IR',\n",
" 'INA at areoid, deg',\n",
" 'EMA at areoid, deg',\n",
" 'Phase angle, deg',\n",
" 'Latitude, areocentric, deg N',\n",
" 'Longitude, areocentric, deg E',\n",
" 'INA at surface from MOLA, deg',\n",
" 'EMA at surface from MOLA, deg',\n",
" 'Slope magnitude from MOLA, deg',\n",
" 'MOLA slope azimuth, deg clkwise from N',\n",
" 'Elevation, meters relative to MOLA',\n",
" 'Thermal inertia, J m^-2 K^-1 s^-0.5',\n",
" 'Bolometic albedo',\n",
" 'Local solar time, hours',\n",
" 'Spare'],\n",
" 'BAND_STORAGE_TYPE': 'BAND_SEQUENTIAL',\n",
" 'LINES': 10,\n",
" 'LINE_SAMPLES': 980,\n",
" 'SAMPLE_BITS': 32,\n",
" 'SAMPLE_TYPE': 'PC_REAL'})\n",
" ('IMAGE_MAP_PROJECTION',\n",
" {'A_AXIS_RADIUS': Quantity(value=3396, units='KM'),\n",
" 'B_AXIS_RADIUS': Quantity(value=3396, units='KM'),\n",
" 'CENTER_LATITUDE': Quantity(value=67.5000001, units='DEGREE'),\n",
" 'CENTER_LONGITUDE': Quantity(value=185.0, units='DEGREE'),\n",
" 'COORDINATE_SYSTEM_NAME': 'PLANETOCENTRIC',\n",
" 'COORDINATE_SYSTEM_TYPE': 'BODY-FIXED ROTATING',\n",
" 'C_AXIS_RADIUS': Quantity(value=3396, units='KM'),\n",
" 'EASTERNMOST_LONGITUDE': Quantity(value=9.9999999, units='DEGREE'),\n",
" 'FIRST_STANDARD_PARALLEL': 'N/A',\n",
" 'LINE_FIRST_PIXEL': 1,\n",
" 'LINE_LAST_PIXEL': 1280,\n",
" 'LINE_PROJECTION_OFFSET': 18560.0,\n",
" 'MAP_PROJECTION_ROTATION': 0.0,\n",
" 'MAP_PROJECTION_TYPE': 'EQUIRECTANGULAR',\n",
" 'MAP_RESOLUTION': Quantity(value=256, units='PIXEL/DEGREE'),\n",
" 'MAP_SCALE': Quantity(value=0.231528833585, units='KM/PIXEL'),\n",
" 'MAXIMUM_LATITUDE': Quantity(value=72.5, units='DEGREE'),\n",
" 'MINIMUM_LATITUDE': Quantity(value=67.5000001, units='DEGREE'),\n",
" 'POSITIVE_LONGITUDE_DIRECTION': 'EAST',\n",
" 'REFERENCE_LATITUDE': 'N/A',\n",
" 'REFERENCE_LONGITUDE': 'N/A',\n",
" 'SAMPLE_FIRST_PIXEL': 1,\n",
" 'SAMPLE_LAST_PIXEL': 980,\n",
" 'SAMPLE_PROJECTION_OFFSET': 47360.0,\n",
" 'SECOND_STANDARD_PARALLEL': 'N/A',\n",
" 'WESTERNMOST_LONGITUDE': Quantity(value=360.0, units='DEGREE'),\n",
" '^DATA_SET_MAP_PROJECTION': 'MRR_MAP.CAT'})\n",
"])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"header"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading