示例#1
0
    def spice0(salt_PSU, temp_C, pres_db, lat, lon):
        """
        Calculate spiciness from glider measurements of salinity and temperature.

        Parameters
        ----------
        salt_PSU : array, dtype=float, shape=[n, ]
            practical salinty
        temp_C : array, dtype=float, shape=[n, ]
        temperature in deg C
        pres_db : array, dtype=float, shape=[n, ]
            pressure in decibar
        lat : array, dtype=float, shape=[n, ]
            latitude in degrees north
        lon : array, dtype=float, shape=[n, ]
            longitude in degrees east

        Returns
        -------
        potential_density : array, dtype=float, shape=[n, ]


        Note
        ----
        Using seawater.dens does not yield the same results as this function. We
        get very close results to what the SeaGlider Basestation returns with this
        function. The difference of this function with the basestation is on
        average ~ 0.003 kg/m3
        """
        import gsw

        salt_abs = gsw.SA_from_SP(salt_PSU, pres_db, lon, lat)
        cons_temp = gsw.CT_from_t(salt_abs, temp_C, pres_db)

        spice0 = gsw.spiciness0(salt_abs, cons_temp)

        spice0 = transfer_nc_attrs(
            getframe(),
            temp_C,
            spice0,
            "spiciness0",
            units=" ",
            comment="",
            standard_name="spiciness0",
        )
        return spice0
示例#2
0
# Load data
tic1 = time.time()
SpiceFile = '/Users/Ellen/Documents/GitHub/BGCArgo_BCGyre/CSVFiles/Spice.csv'
SpiceData = pd.read_csv(SpiceFile)

var_list = SpiceData.columns.to_list()
check = 0
for i in var_list:
    if i == 'Spice':
        check = 1

if check == 0:
    SA = gsw.SA_from_SP(SpiceData.loc[:, 'Sal'], SpiceData.loc[:, 'Pres'],
                        SpiceData.loc[:, 'Lon'], SpiceData.loc[:, 'Lat'])
    CT = gsw.CT_from_t(SA, SpiceData.loc[:, 'Temp'], SpiceData.loc[:, 'Pres'])
    Spicy = gsw.spiciness0(SA, CT)
    SpiceData['Spice'] = Spicy
    SpiceData.to_csv(SpiceFile)

# General plots

for i in np.arange(len(dense_range) - 1):
    tic2 = time.time()
    lower_bound = np.round(dense_range[i], 3)
    upper_bound = np.round(dense_range[i + 1], 3)
    print('\nDense range: ', lower_bound, '-', upper_bound)

    # Load data
    SpiceData = pd.read_csv(
        '/Users/Ellen/Documents/GitHub/BGCArgo_BCGyre/CSVFiles/Spice.csv')
示例#3
0
                    'z': ('height', 'f8', (
                        'profile',
                        'plevel',
                    ), z_from_p(p, lat)),
                    'pt': ('sea_water_potential_temperature', 'f8', (
                        'profile',
                        'plevel',
                    ), pt),
                    'sigma0': ('sea_water_sigmat', 'f8', (
                        'profile',
                        'plevel',
                    ), sigma0(SA, CT)),
                    'spiciness0': ('sea_water_spiciness', 'f8', (
                        'profile',
                        'plevel',
                    ), spiciness0(SA, CT)),
                    'deltaD': ('dynamic_height_anomaly', 'f8', (
                        'profile',
                        'plevel',
                    ), deltaD),
                    'lonv': ('longitude', 'f8', ('profile_vel', ), lonv),
                    'latv': ('latitude', 'f8', ('profile_vel', ), latv),
                    'Vg': ('geostrophic_sea_water_velocity', 'f8', (
                        'profile_vel',
                        'plevel',
                    ), Vg)
                }

                # save data in netcdf file using OceanPy's createNetCDF class
                nc = createNetCDF(output_file)
                nc.add_dims(dim)
示例#4
0
            Parray = np.tile(dict_vars['P'], (dict_vars['S'].shape[1], 1)).T
        elif filename[4:] == 'stations':
            dict_stations['P'] = P

        # calculate TEOS-10 variables and store in dict
        p_ref = 1500
        if filename[4:] == 'vars':
            dict_vars['SA'] = SA_from_SP(dict_vars['S'], Parray,
                                         dict_vars['lon'], dict_vars['lat'])
            dict_vars['CT'] = CT_from_t(dict_vars['SA'], dict_vars['T'],
                                        Parray)
            dict_vars['depth'] = abs(z_from_p(Parray, dict_vars['lat']))
            dict_vars['pt'] = pt_from_t(dict_vars['SA'], dict_vars['T'],
                                        Parray, p_ref)
            dict_vars['sigma0'] = sigma0(dict_vars['SA'], dict_vars['CT'])
            dict_vars['spiciness0'] = spiciness0(dict_vars['SA'],
                                                 dict_vars['CT'])

            # save dictionary to file
            write_dict(dict_vars, path, filename)
            print('data stored in file')

        elif filename[4:] == 'stations':
            for station in dict_ctd['station'][0, :]:
                dict_stations[station]['SA'] = SA_from_SP(
                    dict_stations[station]['S'], dict_stations['P'],
                    dict_stations[station]['lon'],
                    dict_stations[station]['lat'])
                dict_stations[station]['CT'] = CT_from_t(
                    dict_stations[station]['SA'], dict_stations[station]['T'],
                    dict_stations['P'])
                dict_stations[station]['g'] = grav(