<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Written by <NAME>
# based on code developed by <NAME> at NEON and available here:
# https://www.neonscience.org/neon-data-institute-2018
# July 11, 2018
# <EMAIL>

# This script takes as input a hyperspectral imagery hdf5 file from the
# NEON AOP platform, assuming the post-2016 hdf5 format. It was developed as
# part of the 2018 Data Skills Institute at NEON in Boulder, CO. It extracts
# the appropriate metadata from the file and then plots the full spectra for
# a given pixel, which is meant to be passed in as a command-line argument.

# It produces three output figures, one with the entire spectra, and then
# two with the band bands (high noise) marked and then removed. It also will
# output a csv file with the wavelength and reflectance with the bad regions
# removed for the selected pixel.

# For usage parameters, use the -h or --help flag.

#########################################################################
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
#########################################################################

import h5py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from copy import copy
import argparse

# Initialize parser and set up command-line arguments
parser = argparse.ArgumentParser()

parser.add_argument("-v", "--verbose",
                    help="increase output verbosity",
                    action="store_true")

parser.add_argument('-c', '--csvdir',
                    default="./",
                    help="csv file output dir")

parser.add_argument('-f', '--figdir',
                    default="./",
                    help="fig output dir")

parser.add_argument('h5input',
                    help="input h5 file")

parser.add_argument('ycoord',
                    type=int,
                    help="y coord of pixel to plot")

parser.add_argument('xcoord',
                    type=int,
                    help="x coord of pixel to plot")

args = parser.parse_args()

if args.verbose:
    print("Verbosity turned on.")


# capture filename
refl_filename = args.h5input


# capture desired pixel
# note that this is y, x, spectra
# NOT x, y, spectra
pixel_to_plot = (args.ycoord, args.xcoord)
if args.verbose:
    print("pixel_to_plot\n", ', '.join(map(str, pixel_to_plot)))


# read in reflectance hdf5 file
hdf5_file = h5py.File(refl_filename, 'r')
if args.verbose:
    print("hdf5_file\n", hdf5_file)

<commit_msg>Add filename to verbose output<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Written by <NAME>
# based on code developed by <NAME> at NEON and available here:
# https://www.neonscience.org/neon-data-institute-2018
# July 11, 2018
# <EMAIL>

# This script takes as input a hyperspectral imagery hdf5 file from the
# NEON AOP platform, assuming the post-2016 hdf5 format. It was developed as
# part of the 2018 Data Skills Institute at NEON in Boulder, CO. It extracts
# the appropriate metadata from the file and then plots the full spectra for
# a given pixel, which is meant to be passed in as a command-line argument.

# It produces three output figures, one with the entire spectra, and then
# two with the band bands (high noise) marked and then removed. It also will
# output a csv file with the wavelength and reflectance with the bad regions
# removed for the selected pixel.

# For usage parameters, use the -h or --help flag.

#########################################################################
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
#########################################################################

import h5py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from copy import copy
import argparse

# Initialize parser and set up command-line arguments
parser = argparse.ArgumentParser()

parser.add_argument("-v", "--verbose",
                    help="increase output verbosity",
                    action="store_true")

parser.add_argument('-c', '--csvdir',
                    default="./",
                    help="csv file output dir")

parser.add_argument('-f', '--figdir',
                    default="./",
                    help="fig output dir")

parser.add_argument('h5input',
                    help="input h5 file")

parser.add_argument('ycoord',
                    type=int,
                    help="y coord of pixel to plot")

parser.add_argument('xcoord',
                    type=int,
                    help="x coord of pixel to plot")

args = parser.parse_args()

if args.verbose:
    print("Verbosity turned on.")


# capture filename
refl_filename = args.h5input
if args.verbose:
    print("filename being processed:\n", args.h5input)

# capture desired pixel
# note that this is y, x, spectra
# NOT x, y, spectra
pixel_to_plot = (args.ycoord, args.xcoord)
if args.verbose:
    print("pixel_to_plot\n", ', '.join(map(str, pixel_to_plot)))


# read in reflectance hdf5 file
hdf5_file = h5py.File(refl_filename, 'r')
if args.verbose:
    print("hdf5_file\n", hdf5_file)


{'fraction_non_alphanumeric': 0.11786766675596036, 'fraction_numerical': 0.008170372354674525, 'mean_word_length': 3.431454005934718, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7066024', 'n_tokens_mistral': 2087, 'n_tokens_neox': 1957, 'n_words': 912}