def get_profile(data, z_col, z_start, p_col, P, z_min, z_max, nr, nc): """ Run the ambient.extract_profile function and test that the data are correctly parsed per the inputs given above. """ # Apply the profile extraction function prof_data = ambient.extract_profile(data, z_col=z_col, z_start=z_start, p_col=p_col, P_atm=P) # Check that the returned profile extends to the free surface assert prof_data[0,z_col] == 0.0 # Check that the profile is clipped at the expected depths assert_approx_equal(prof_data[1,z_col], z_min, significant = 6) assert_approx_equal(prof_data[-1,z_col], z_max, significant = 6) # Check that the returned profile is the right shape and data type assert prof_data.shape[0] == nr if nc is not None: assert prof_data.shape[1] == nc assert isinstance(prof_data, np.ndarray) # Check the that returned profile is in ascending order for i in range(1, prof_data.shape[0]): assert prof_data[i,z_col] > prof_data[i-1,z_col] # Send back the extracted profile return prof_data
def get_profile(data, z_col, z_start, p_col, P, z_min, z_max, nr, nc): """ Run the ambient.extract_profile function and test that the data are correctly parsed per the inputs given above. """ # Apply the profile extraction function prof_data = ambient.extract_profile(data, z_col=z_col, z_start=z_start, p_col=p_col, P_atm=P) # Check that the returned profile extends to the free surface assert prof_data[0, z_col] == 0.0 # Check that the profile is clipped at the expected depths assert_approx_equal(prof_data[1, z_col], z_min, significant=6) assert_approx_equal(prof_data[-1, z_col], z_max, significant=6) # Check that the returned profile is the right shape and data type assert prof_data.shape[0] == nr if nc is not None: assert prof_data.shape[1] == nc assert isinstance(prof_data, np.ndarray) # Check the that returned profile is in ascending order for i in range(1, prof_data.shape[0]): assert prof_data[i, z_col] > prof_data[i - 1, z_col] # Send back the extracted profile return prof_data
def get_ctd_profile(): """ Load the ASCII CTD Data into an 'ambient.Profile' object. This function performs the steps in ./profile_from_ctd.py to read in the CTD data and create a Profile object. This is the data set that will be used to demonstrate how to append data to a Profiile object. """ # Get the path to the input file __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__), '../../tamoc/data')) dat_file = os.path.join(__location__,'ctd_BM54.cnv') # Load in the data using numpy.loadtxt raw = np.loadtxt(dat_file, comments = '#', skiprows = 175, usecols = (0, 1, 3, 8, 9, 10, 12)) # Describe the organization of the data in raw. var_names = ['temperature', 'pressure', 'wetlab_fluorescence', 'z', 'salinity', 'density', 'oxygen'] var_units = ['deg C', 'db', 'mg/m^3', 'm', 'psu', 'kg/m^3', 'mg/l'] z_col = 3 # Clean the profile to remove reversals in the depth coordinate data = ambient.extract_profile(raw, z_col, 50.0) # Convert the profile data to standard units in TAMOC profile, units = ambient.convert_units(data, var_units) # Create an empty netCDF4-classic dataset to store this CTD data __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__), '../../test/output')) nc_file = os.path.join(__location__,'BM54.nc') summary = 'Dataset created by profile_from_ctd in the ./bin directory' \ + ' of TAMOC' source = 'R/V Brooks McCall, station BM54' sea_name = 'Gulf of Mexico' p_lat = 28.0 + 43.945 / 60.0 p_lon = 360 - (88.0 + 22.607 / 60.0) p_time = date2num(datetime(2010, 5, 30, 18, 22, 12), units = 'seconds since 1970-01-01 00:00:00 0:00', calendar = 'julian') nc = ambient.create_nc_db(nc_file, summary, source, sea_name, p_lat, p_lon, p_time) # Insert the CTD data into the netCDF dataset comments = ['measured'] * len(var_names) nc = ambient.fill_nc_db(nc, profile, var_names, units, comments, z_col) # Create an ambient.Profile object for this dataset bm54 = ambient.Profile(nc, chem_names=['oxygen']) # Return the Profile object return bm54
if __name__ == '__main__': # Get the path to the input file __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__), '../../tamoc/data')) C_file = os.path.join(__location__, 'C.dat') T_file = os.path.join(__location__, 'T.dat') # Load in the data using numpy.loadtxt C_raw = np.loadtxt(C_file, comments='%') T_raw = np.loadtxt(T_file, comments='%') # Clean the profiles to remove depth reversals C_data = ambient.extract_profile(C_raw, 1, 25.0) T_data = ambient.extract_profile(T_raw, 1, 25.0) # Convert the data to standard units C_profile, C_units = ambient.convert_units(C_data, ['psu', 'm']) T_profile, T_units = ambient.convert_units(T_data, ['deg C', 'm']) # Create an empty netCDF4-classic dataset to store this CTD data __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__), '../../test/output')) nc_file = os.path.join(__location__, 'DS.nc') summary = 'Dataset created by profile_from_txt in the ./bin directory' \ + ' of TAMOC' source = 'Digitized data from the average CTD profile in the SINTEF ' + \ 'DeepSpill Report'
def get_ctd_profile(): """ Load the ASCII CTD Data into an `ambient.Profile` object. This function performs the steps in ./profile_from_ctd.py to read in the CTD data and create a Profile object. This is the data set that will be used to demonstrate how to append data to a Profile object. """ # Get the path to the input file __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__), '../../tamoc/data')) dat_file = os.path.join(__location__, 'ctd_BM54.cnv') # Load in the data using numpy.loadtxt raw = np.loadtxt(dat_file, comments='#', skiprows=175, usecols=(0, 1, 3, 8, 9, 10, 12)) # Describe the organization of the data in raw. var_names = [ 'temperature', 'pressure', 'wetlab_fluorescence', 'z', 'salinity', 'density', 'oxygen' ] var_units = ['deg C', 'db', 'mg/m^3', 'm', 'psu', 'kg/m^3', 'mg/l'] z_col = 3 # Clean the profile to remove reversals in the depth coordinate data = ambient.extract_profile(raw, z_col, 50.0) # Convert the profile data to standard units in TAMOC profile, units = ambient.convert_units(data, var_units) # Create an empty netCDF4-classic dataset to store this CTD data __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__), '../../test/output')) nc_file = os.path.join(__location__, 'BM54.nc') summary = 'Dataset created by profile_from_ctd in the ./bin directory' \ + ' of TAMOC' source = 'R/V Brooks McCall, station BM54' sea_name = 'Gulf of Mexico' p_lat = 28.0 + 43.945 / 60.0 p_lon = 360 - (88.0 + 22.607 / 60.0) p_time = date2num(datetime(2010, 5, 30, 18, 22, 12), units='seconds since 1970-01-01 00:00:00 0:00', calendar='julian') nc = ambient.create_nc_db(nc_file, summary, source, sea_name, p_lat, p_lon, p_time) # Insert the CTD data into the netCDF dataset comments = ['measured'] * len(var_names) nc = ambient.fill_nc_db(nc, profile, var_names, units, comments, z_col) # Create an ambient.Profile object for this dataset bm54 = ambient.Profile(nc, chem_names=['oxygen']) # Return the Profile object return bm54
if __name__ == '__main__': # Get the path to the input file __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__), '../../tamoc/data')) C_file = os.path.join(__location__,'C.dat') T_file = os.path.join(__location__,'T.dat') # Load in the data using numpy.loadtxt C_raw = np.loadtxt(C_file, comments = '%') T_raw = np.loadtxt(T_file, comments = '%') # Clean the profiles to remove depth reversals C_data = ambient.extract_profile(C_raw, 1, 25.0) T_data = ambient.extract_profile(T_raw, 1, 25.0) # Convert the data to standard units C_profile, C_units = ambient.convert_units(C_data, ['psu', 'm']) T_profile, T_units = ambient.convert_units(T_data, ['deg C', 'm']) # Create an empty netCDF4-classic dataset to store this CTD data __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__), '../../test/output')) nc_file = os.path.join(__location__,'DS.nc') summary = 'Dataset created by profile_from_txt in the ./bin directory' \ + ' of TAMOC' source = 'Digitized data from the average CTD profile in the SINTEF ' + \ 'DeepSpill Report'
# Load in the data using numpy.loadtxt raw = np.loadtxt(dat_file, comments='#', skiprows=175, usecols=(0, 1, 3, 8, 9, 10, 12)) # Describe the organization of the data in raw. var_names = [ 'temperature', 'pressure', 'wetlab_fluorescence', 'z', 'salinity', 'density', 'oxygen' ] var_units = ['deg C', 'db', 'mg/m^3', 'm', 'psu', 'kg/m^3', 'mg/l'] z_col = 3 # Clean the profile to remove reversals in the depth coordinate data = ambient.extract_profile(raw, z_col, 50.0) # Convert the profile data to standard units in TAMOC profile, units = ambient.convert_units(data, var_units) # Create an empty netCDF4-classic dataset to store this CTD data __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__), '../../test/output')) nc_file = os.path.join(__location__, 'BM54.nc') summary = 'Dataset created by profile_from_ctd in the ./bin directory' \ + ' of TAMOC' source = 'R/V Brooks McCall, station BM54' sea_name = 'Gulf of Mexico' p_lat = 28.0 + 43.945 / 60.0 p_lon = 360 - (88.0 + 22.607 / 60.0)
os.path.dirname(__file__), '../../tamoc/data')) dat_file = os.path.join(__location__,'ctd_BM54.cnv') # Load in the data using numpy.loadtxt raw = np.loadtxt(dat_file, comments = '#', skiprows = 175, usecols = (0, 1, 3, 8, 9, 10, 12)) # Describe the organization of the data in raw. var_names = ['temperature', 'pressure', 'wetlab_fluorescence', 'z', 'salinity', 'density', 'oxygen'] var_units = ['deg C', 'db', 'mg/m^3', 'm', 'psu', 'kg/m^3', 'mg/l'] z_col = 3 # Clean the profile to remove reversals in the depth coordinate data = ambient.extract_profile(raw, z_col, 50.0) # Convert the profile data to standard units in TAMOC profile, units = ambient.convert_units(data, var_units) # Create an empty netCDF4-classic dataset to store this CTD data __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__), '../../test/output')) nc_file = os.path.join(__location__,'BM54.nc') summary = 'Dataset created by profile_from_ctd in the ./bin directory' \ + ' of TAMOC' source = 'R/V Brooks McCall, station BM54' sea_name = 'Gulf of Mexico' p_lat = 28.0 + 43.945 / 60.0 p_lon = 360 - (88.0 + 22.607 / 60.0)