<jupyter_start><jupyter_text>Visualize the raster<jupyter_code>#ASO is airborne coupled imaging spectrometer (measures snow albedo) and lidar (elevation)

#path to raster
raster_path = '/home/jovyan/shared/data-aragon/ASO_3M_PCDTM_USCOGE_20180908_20180913.tif'
#raster_path = '/home/jovyan/shared/data-aragon/ASO_3M_PCDTM_USCOCM_20180912_20180913.tif'
#raster_path = '/home/jovyan/shared/data-aragon/ASO_3M_PCDTM_USCOGT_20180912_20180913.tif'
#raster_path = '/home/jovyan/shared/data-aragon/ASO_3M_PCDTM_USCATE_20191010_20191010.tif'


ds = rio.open(raster_path)
dem = ds.read(1)
dem = np.ma.masked_equal(dem,gda_lib.get_ndv(ds))
xmin,ymin,xmax,ymax = ds.bounds
ds.crs
print(xmax-xmin,ymax-ymin)
raster = rio.open(raster_path)
raster.meta
fig,ax = plt.subplots(figsize=(10,8))

rio.plot.show(dem, ax=ax,cmap='gray')
[L,B,R,T] = subsetBBox(raster_path,raster.crs,'epsg:4326') # now read projection from DEM, convert to WGS84
    #[L,B,R,T] = subsetBBox(raster,'epsg:32611','epsg:4326')
    # Area of interest
boundaries = {
    'LowerLeft_Lon': L,
    'LowerLeft_Lat': B,
    'UpperRight_Lon': R,
    'UpperRight_Lat': T,
}
L,B,R,T<jupyter_output><empty_output><jupyter_text>Find Icesat2 data within domainFrom intro-is-files Notebook<jupyter_code>from pathlib import Path

# Our data folder 
#data_home = Path('/home/jovyan/tutorial-data/land_ice_applications/PIG_ATL06')
data_home = Path('/home/jovyan/shared/data-Isobel_Rosie/ATL03')
                 
# Create folder if it doesn't exist
data_home.mkdir(exist_ok=True)
from icepyx import icesat2data as ipd

short_name = 'ATL03'
spatial_extent = [L,B,R,T]
date_range = ['2018-01-01','2020-06-17']

# spatial_extent = [148, -81, 162, -80]  # Byrd
# date_range = ['2018-10-14','2018-12-22']

region = ipd.Icesat2Data(short_name, spatial_extent, date_range)
print('product:    ', region.dataset)
print('dates:      ', region.dates)
print('start time: ', region.start_time)
print('end time:   ', region.end_time)
print('version:    ', region.dataset_version)
print('extent:     ', region.spatial_extent)

print('\nDATA:')
print('\n'.join([str(item) for item in region.avail_granules().items()]))

region.visualize_spatial_extent()
#build and view the parameters that will be submitted in our query
region.CMRparams
#get a list of the available granule IDs that meet your search criteria
region.avail_granules(ids=True)<jupyter_output><empty_output><jupyter_text>Download the data<jupyter_code>name = 'isobelrlawrence'
email = '<EMAIL>'

for file in region.avail_granules(ids=True):
    print(file)
    if not list(data_home.glob('*'+file+'*')):
        print('you dont have the file')
        region.earthdata_login(name, email)
        region.download_granules(data_home)
# Only download if data folder is empty
#if not list(data_home.glob('*.h5')):
#    region.earthdata_login(name, email)
#    region.download_granules(data_home)
files = list(data_home.glob('*.h5'))

for f in files[:10]: print(f)
print('Total number of files:', len(files))<jupyter_output>/home/jovyan/shared/data-Isobel_Rosie/ATL03/processed_ATL03_20191008052407_01730502_003_01.h5
Total number of files: 1<jupyter_text>Plot the ATL03 data From land_ice_applications Notebook<jupyter_code># the usual suspects:
import numpy as np
import matplotlib.pyplot as plt

# specialty modules
import h5py
import pyproj

# run matplotlib in 'widget' mode
%matplotlib widget
%load_ext autoreload
%autoreload 2
#from readers.read_HDF5_ATL03 import read_HDF5_ATL03
#from readers.get_ATL03_x_atc import get_ATL03_x_atc

from read_HDF5_ATL03 import read_HDF5_ATL03
from get_ATL03_x_atc import get_ATL03_x_atc
data_root='/home/jovyan/shared/data-aragon/'
import os
import glob

rgt="0615"
cycle="04"
glob.glob(os.path.join(data_root, 'download', f'*{rgt}{cycle}*.h5'))
read_HDF5_ATL03
# read the data:
rgt="0615"
cycle="04"
# read the IS2 data with Tyler's ATL03 reader:
ATL03_file=glob.glob(os.path.join(data_root, 'download', f'*{rgt}{cycle}*.h5'))[0]
print(ATL03_file)
IS2_atl03_mds, IS2_atl03_attrs, IS2_atl03_beams =read_HDF5_ATL03(ATL03_file)
# add x_atc to the ATL03 data structure (this function adds to the LS2_ATL03_mds dictionary)
get_ATL03_x_atc(IS2_atl03_mds, IS2_atl03_attrs, IS2_atl03_beams)
#-- select the beam from ATL03
D3 = IS2_atl03_mds['gt3l']

#-- create scatter plot of photon data (e.g., photon elevation vs x_atc)
fig=plt.figure(figsize=(6,4))
ax = fig.add_subplot(111)
ax.plot(D3['heights']['x_atc'], D3['heights']['h_ph'],'k.',markersize=0.25, label='all photons')
LMH=D3['heights']['signal_conf_ph'][:,3] >= 2
ax.plot(D3['heights']['x_atc'][LMH], D3['heights']['h_ph'][LMH],'g.',markersize=0.5, label='flagged photons')
h_leg=ax.legend()

ax.set_xlabel('x_atc, m')
ax.set_ylabel('h, m')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13997477931904162, 'fraction_numerical': 0.05842791088692728, 'mean_word_length': 6.276758409785932, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '411890', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1945, 'n_words': 349, 'path': 'contributors/IsobelLawrence/findASO_intersect_IRL.ipynb', 'repo_name': 'tedmaksym/SeasonalSnow', 'size': '4779'}