コード例 #1
0
    def __init__(self,yearmon,basin,uname):
        self.yearmon = yearmon
        self.uname = uname
        basinname = {'pac':'Pacific Ocean','atl':'Atlantic Ocean','gom':'Gulf of Mexico'}
        self.read_ww3_spec_netcdf()
        self.read_ww3_dep_netcdf()
        self.read_ww3_ustar_netcdf()
        self.time2date()
        self.results = []
        outtype = {'time':'f8','datetime':'int','wavhs':'f4','wavtp':'f4','wavtpp':'f4','wavetm':'f4','wavtm1':'f4','wavtm2':'f4','wavdir':'f4','wavspr':'f4','frequency':'f4','direction':'f4','ef2d':'f4','wndspd':'f4','wnddir':'f4','ustar':'f4','cd':'f4','ef2d_swell':'f4','ef2d_wndsea':'f4','wavhs_wndsea':'f4','wavtp_wndsea':'f4','wavtpp_wndsea':'f4','wavetm_wndsea':'f4','wavtm1_wndsea':'f4','wavtm2_wndsea':'f4','wavdir_wndsea':'f4','wavspr_wndsea':'f4','wavhs_swell':'f4','wavtp_swell':'f4','wavtpp_swell':'f4','wavetm_swell':'f4','wavtm1_swell':'f4','wavtm2_swell':'f4','wavdir_swell':'f4','wavspr_swell':'f4'}

        for ii,stat in self.station.items():
            ef = self.ef2d[:,ii,:,:].reshape(len(self.time),len(self.freq),len(self.direc))
            wavhs = wp.calc_wvht(ef,self.freq,self.direc)
            wavtp,wavtpp = wp.calc_peak_period(ef,self.freq,self.direc)
            wavtm = wp.calc_mean_period(ef,self.freq,self.direc)
            wavtm1,wavtm2 = wp.calc_tm1_tm2(ef,self.freq,self.direc)
            wavdir,wavspr = wp.calc_wave_direction(ef,self.freq,self.direc)

            efswell,efwndsea = wp.calc_windsea_swell(ef,self.freq,self.direc,self.ustar[:,ii],self.wnddir[:,ii])       
     
            wavhs_wndsea = wp.calc_wvht(efwndsea,self.freq,self.direc)
            wavtp_wndsea,wavtpp_wndsea = wp.calc_peak_period(efwndsea,self.freq,self.direc)
            wavtm_wndsea = wp.calc_mean_period(efwndsea,self.freq,self.direc)
            wavtm1_wndsea,wavtm2_wndsea = wp.calc_tm1_tm2(efwndsea,self.freq,self.direc)
            wavdir_wndsea,wavspr_wndsea = wp.calc_wave_direction(efwndsea,self.freq,self.direc)

            wavhs_swell = wp.calc_wvht(efswell,self.freq,self.direc)
            wavtp_swell,wavtpp_swell = wp.calc_peak_period(efswell,self.freq,self.direc)
            wavtm_swell = wp.calc_mean_period(efswell,self.freq,self.direc)
            wavtm1_swell,wavtm2_swell = wp.calc_tm1_tm2(efswell,self.freq,self.direc)
            wavdir_swell,wavspr_swell = wp.calc_wave_direction(efswell,self.freq,self.direc)


            data = {'time':self.pytime,'datetime':self.dattime,'wavhs':wavhs,'wavtp':wavtp,'wavtpp':wavtpp,'wavtm1':wavtm1,'wavtm2':wavtm2,'wavdir':wavdir,'wavspr':wavspr,'frequency':np.array(self.freq),'direction':np.array(self.direc),'ef2d':np.array(ef),'wndspd':self.wndspd[:,ii],'wnddir':self.wnddir[:,ii],'ustar':self.ustar[:,ii],'cd':self.cd[:,ii],'ef2d_swell':efswell,'ef2d_wndsea':efwndsea,'wavhs_wndsea':wavhs_wndsea,'wavtp_wndsea':wavtp_wndsea,'wavtpp_wndsea':wavtpp_wndsea,'wavtm1_wndsea':wavtm1_wndsea,'wavtm2_wndsea':wavtm2_wndsea,'wavdir_wndsea':wavdir_wndsea,'wavspr_wndsea':wavspr_wndsea,'wavhs_swell':wavhs_swell,'wavtp_swell':wavtp_swell,'wavtpp_swell':wavtpp_swell,'wavtm1_swell':wavtm1_swell,'wavtm2_swell':wavtm2_swell,'wavdir_swell':wavdir_swell,'wavspr_swell':wavspr_swell}
            info = {'station':stat,'longitude':self.longitude[ii],'latitude':self.latitude[ii],'outtype':outtype,'depth':self.depth[ii],'uname':self.uname,'basin':basinname[basin]}
            dd = {'info':info,'data':data}
            self.results.append(dd)

            wh5.write_stat_h5(self.results[ii])
コード例 #2
0
ファイル: ww3_netcdf.py プロジェクト: CHL-WIS/WIS_ATL
    def __init__(self, yearmon, basin):
        self.yearmon = yearmon
        self.year = yearmon[:4]
        self.mon = yearmon[4:]
        # 	self.grid = grid
        basinname = {"pac": "Pacific Ocean", "atl": "Atlantic Ocean", "gom": "Gulf of Mexico"}

        self.read_ww3_spec_netcdf()
        #        self.read_ww3_dep_netcdf()
        self.read_ww3_ustar_netcdf()
        self.time2date()
        self.results = []
        # 'datetime':'i4'
        outtype = {
            "time": "i4",
            "wavehs": "f4",
            "wavetp": "f4",
            "wavetpp": "f4",
            "wavetm": "f4",
            "wavetm1": "f4",
            "wavetm2": "f4",
            "wavedir": "f4",
            "wavespr": "f4",
            "frequency": "f4",
            "direction": "f4",
            "ef2d": "f4",
            "windspeed": "f4",
            "winddir": "f4",
            "ustar": "f4",
            "cd": "f4",
            "ef2d_swell": "f4",
            "ef2d_wndsea": "f4",
            "wavehs_wndsea": "f4",
            "wavetp_wndsea": "f4",
            "wavetpp_wndsea": "f4",
            "wavetm_wndsea": "f4",
            "wavetm1_wndsea": "f4",
            "wavetm2_wndsea": "f4",
            "wavedir_wndsea": "f4",
            "wavespr_wndsea": "f4",
            "wavehs_swell": "f4",
            "wavetp_swell": "f4",
            "wavetpp_swell": "f4",
            "wavetm_swell": "f4",
            "wavetm1_swell": "f4",
            "wavetm2_swell": "f4",
            "wavedir_swell": "f4",
            "wavespr_swell": "f4",
        }
        # 'datetime':{0:'time',1:'date'}
        outshape = {
            "time": "time",
            "wavehs": "time",
            "wavetp": "time",
            "wavetpp": "time",
            "wavetm": "time",
            "wavetm1": "time",
            "wavetm2": "time",
            "wavedir": "time",
            "wavespr": "time",
            "frequency": "freq",
            "direction": "direc",
            "ef2d": {0: "time", 1: "freq", 2: "direc"},
            "windspeed": "time",
            "winddir": "time",
            "ustar": "time",
            "cd": "time",
            "ef2d_swell": {0: "time", 1: "freq", 2: "direc"},
            "ef2d_wndsea": {0: "time", 1: "freq", 2: "direc"},
            "wavehs_wndsea": "time",
            "wavetp_wndsea": "time",
            "wavetpp_wndsea": "time",
            "wavetm_wndsea": "time",
            "wavetm1_wndsea": "time",
            "wavetm2_wndsea": "time",
            "wavedir_wndsea": "time",
            "wavespr_wndsea": "time",
            "wavehs_swell": "time",
            "wavetp_swell": "time",
            "wavetpp_swell": "time",
            "wavetm_swell": "time",
            "wavetm1_swell": "time",
            "wavetm2_swell": "time",
            "wavedir_swell": "time",
            "wavespr_swell": "time",
        }
        for ii, stat in self.station.items():
            ef = self.ef2d[:, ii, :, :].reshape(len(self.time), len(self.freq), len(self.direc))
            wavhs = wp.calc_wvht(ef, self.freq, self.direc)
            wavtp, wavtpp = wp.calc_peak_period(ef, self.freq, self.direc)
            wavtm = wp.calc_mean_period(ef, self.freq, self.direc)
            wavtm1, wavtm2 = wp.calc_tm1_tm2(ef, self.freq, self.direc)
            wavdir, wavspr = wp.calc_wave_direction(ef, self.freq, self.direc)

            efswell, efwndsea = wp.calc_windsea_swell(ef, self.freq, self.direc, self.ustar[:, ii], self.wnddir[:, ii])

            wavhs_wndsea = wp.calc_wvht(efwndsea, self.freq, self.direc)
            wavtp_wndsea, wavtpp_wndsea = wp.calc_peak_period(efwndsea, self.freq, self.direc)
            wavtm_wndsea = wp.calc_mean_period(efwndsea, self.freq, self.direc)
            wavtm1_wndsea, wavtm2_wndsea = wp.calc_tm1_tm2(efwndsea, self.freq, self.direc)
            wavdir_wndsea, wavspr_wndsea = wp.calc_wave_direction(efwndsea, self.freq, self.direc)

            wavhs_swell = wp.calc_wvht(efswell, self.freq, self.direc)
            wavtp_swell, wavtpp_swell = wp.calc_peak_period(efswell, self.freq, self.direc)
            wavtm_swell = wp.calc_mean_period(efswell, self.freq, self.direc)
            wavtm1_swell, wavtm2_swell = wp.calc_tm1_tm2(efswell, self.freq, self.direc)
            wavdir_swell, wavspr_swell = wp.calc_wave_direction(efswell, self.freq, self.direc)

            # 'datetime':self.dattime
            data = {
                "time": self.pytime,
                "wavehs": wavhs,
                "wavetp": wavtp,
                "wavetpp": wavtpp,
                "wavetm": wavtm,
                "wavetm1": wavtm1,
                "wavetm2": wavtm2,
                "wavedir": wavdir,
                "wavespr": wavspr,
                "frequency": np.array(self.freq),
                "direction": np.array(self.direc),
                "ef2d": np.array(ef),
                "windspeed": self.wndspd[:, ii],
                "winddir": self.wnddir[:, ii],
                "ustar": self.ustar[:, ii],
                "cd": self.cd[:, ii],
                "ef2d_swell": efswell,
                "ef2d_wndsea": efwndsea,
                "wavehs_wndsea": wavhs_wndsea,
                "wavetp_wndsea": wavtp_wndsea,
                "wavetpp_wndsea": wavtpp_wndsea,
                "wavetm_wndsea": wavtm_wndsea,
                "wavetm1_wndsea": wavtm1_wndsea,
                "wavetm2_wndsea": wavtm2_wndsea,
                "wavedir_wndsea": wavdir_wndsea,
                "wavespr_wndsea": wavspr_wndsea,
                "wavehs_swell": wavhs_swell,
                "wavetp_swell": wavtp_swell,
                "wavetpp_swell": wavtpp_swell,
                "wavetm_swell": wavtm_swell,
                "wavetm1_swell": wavtm1_swell,
                "wavetm2_swell": wavtm2_swell,
                "wavedir_swell": wavdir_swell,
                "wavespr_swell": wavspr_swell,
            }
            info = {
                "station": stat,
                "longitude": self.longitude[ii],
                "latitude": self.latitude[ii],
                "outtype": outtype,
                "depth": self.depth[ii],
                "basin": basinname[basin],
                "outshape": outshape,
                "timestart": self.timestart,
                "timeend": self.timeend,
                "year": self.year,
                "month": self.mon,
            }
            dd = {"info": info, "data": data}
            self.results.append(dd)

            #        wh5.write_stat_h5(self.results[ii])
            wnc.write_stat_nc(self.results[ii])
コード例 #3
0
    def __init__(self, yearmon, basin, uname):
        self.yearmon = yearmon
        self.uname = uname
        basinname = {
            'pac': 'Pacific Ocean',
            'atl': 'Atlantic Ocean',
            'gom': 'Gulf of Mexico'
        }
        self.read_ww3_spec_netcdf()
        self.read_ww3_dep_netcdf()
        self.read_ww3_ustar_netcdf()
        self.time2date()
        self.results = []
        outtype = {
            'time': 'f8',
            'datetime': 'int',
            'wavhs': 'f4',
            'wavtp': 'f4',
            'wavtpp': 'f4',
            'wavetm': 'f4',
            'wavtm1': 'f4',
            'wavtm2': 'f4',
            'wavdir': 'f4',
            'wavspr': 'f4',
            'frequency': 'f4',
            'direction': 'f4',
            'ef2d': 'f4',
            'wndspd': 'f4',
            'wnddir': 'f4',
            'ustar': 'f4',
            'cd': 'f4',
            'ef2d_swell': 'f4',
            'ef2d_wndsea': 'f4',
            'wavhs_wndsea': 'f4',
            'wavtp_wndsea': 'f4',
            'wavtpp_wndsea': 'f4',
            'wavetm_wndsea': 'f4',
            'wavtm1_wndsea': 'f4',
            'wavtm2_wndsea': 'f4',
            'wavdir_wndsea': 'f4',
            'wavspr_wndsea': 'f4',
            'wavhs_swell': 'f4',
            'wavtp_swell': 'f4',
            'wavtpp_swell': 'f4',
            'wavetm_swell': 'f4',
            'wavtm1_swell': 'f4',
            'wavtm2_swell': 'f4',
            'wavdir_swell': 'f4',
            'wavspr_swell': 'f4'
        }

        for ii, stat in self.station.items():
            ef = self.ef2d[:, ii, :, :].reshape(len(self.time), len(self.freq),
                                                len(self.direc))
            wavhs = wp.calc_wvht(ef, self.freq, self.direc)
            wavtp, wavtpp = wp.calc_peak_period(ef, self.freq, self.direc)
            wavtm = wp.calc_mean_period(ef, self.freq, self.direc)
            wavtm1, wavtm2 = wp.calc_tm1_tm2(ef, self.freq, self.direc)
            wavdir, wavspr = wp.calc_wave_direction(ef, self.freq, self.direc)

            efswell, efwndsea = wp.calc_windsea_swell(ef, self.freq,
                                                      self.direc,
                                                      self.ustar[:, ii],
                                                      self.wnddir[:, ii])

            wavhs_wndsea = wp.calc_wvht(efwndsea, self.freq, self.direc)
            wavtp_wndsea, wavtpp_wndsea = wp.calc_peak_period(
                efwndsea, self.freq, self.direc)
            wavtm_wndsea = wp.calc_mean_period(efwndsea, self.freq, self.direc)
            wavtm1_wndsea, wavtm2_wndsea = wp.calc_tm1_tm2(
                efwndsea, self.freq, self.direc)
            wavdir_wndsea, wavspr_wndsea = wp.calc_wave_direction(
                efwndsea, self.freq, self.direc)

            wavhs_swell = wp.calc_wvht(efswell, self.freq, self.direc)
            wavtp_swell, wavtpp_swell = wp.calc_peak_period(
                efswell, self.freq, self.direc)
            wavtm_swell = wp.calc_mean_period(efswell, self.freq, self.direc)
            wavtm1_swell, wavtm2_swell = wp.calc_tm1_tm2(
                efswell, self.freq, self.direc)
            wavdir_swell, wavspr_swell = wp.calc_wave_direction(
                efswell, self.freq, self.direc)

            data = {
                'time': self.pytime,
                'datetime': self.dattime,
                'wavhs': wavhs,
                'wavtp': wavtp,
                'wavtpp': wavtpp,
                'wavtm1': wavtm1,
                'wavtm2': wavtm2,
                'wavdir': wavdir,
                'wavspr': wavspr,
                'frequency': np.array(self.freq),
                'direction': np.array(self.direc),
                'ef2d': np.array(ef),
                'wndspd': self.wndspd[:, ii],
                'wnddir': self.wnddir[:, ii],
                'ustar': self.ustar[:, ii],
                'cd': self.cd[:, ii],
                'ef2d_swell': efswell,
                'ef2d_wndsea': efwndsea,
                'wavhs_wndsea': wavhs_wndsea,
                'wavtp_wndsea': wavtp_wndsea,
                'wavtpp_wndsea': wavtpp_wndsea,
                'wavtm1_wndsea': wavtm1_wndsea,
                'wavtm2_wndsea': wavtm2_wndsea,
                'wavdir_wndsea': wavdir_wndsea,
                'wavspr_wndsea': wavspr_wndsea,
                'wavhs_swell': wavhs_swell,
                'wavtp_swell': wavtp_swell,
                'wavtpp_swell': wavtpp_swell,
                'wavtm1_swell': wavtm1_swell,
                'wavtm2_swell': wavtm2_swell,
                'wavdir_swell': wavdir_swell,
                'wavspr_swell': wavspr_swell
            }
            info = {
                'station': stat,
                'longitude': self.longitude[ii],
                'latitude': self.latitude[ii],
                'outtype': outtype,
                'depth': self.depth[ii],
                'uname': self.uname,
                'basin': basinname[basin]
            }
            dd = {'info': info, 'data': data}
            self.results.append(dd)

            wh5.write_stat_h5(self.results[ii])
コード例 #4
0
ファイル: ww3_netcdf.py プロジェクト: CHL-WIS/WIS_ATL
    def __init__(self, yearmon, basin):
        self.yearmon = yearmon
        self.year = yearmon[:4]
        self.mon = yearmon[4:]
        #	self.grid = grid
        basinname = {
            'pac': 'Pacific Ocean',
            'atl': 'Atlantic Ocean',
            'gom': 'Gulf of Mexico'
        }

        self.read_ww3_spec_netcdf()
        #        self.read_ww3_dep_netcdf()
        self.read_ww3_ustar_netcdf()
        self.time2date()
        self.results = []
        # 'datetime':'i4'
        outtype = {'time':'i4','wavehs':'f4','wavetp':'f4','wavetpp':'f4','wavetm':'f4','wavetm1':'f4','wavetm2':'f4', \
                       'wavedir':'f4','wavespr':'f4','frequency':'f4','direction':'f4','ef2d':'f4','windspeed':'f4','winddir':'f4','ustar':'f4', \
                       'cd':'f4','ef2d_swell':'f4','ef2d_wndsea':'f4','wavehs_wndsea':'f4','wavetp_wndsea':'f4','wavetpp_wndsea':'f4', \
                       'wavetm_wndsea':'f4','wavetm1_wndsea':'f4','wavetm2_wndsea':'f4','wavedir_wndsea':'f4','wavespr_wndsea':'f4','wavehs_swell':'f4', \
                       'wavetp_swell':'f4','wavetpp_swell':'f4','wavetm_swell':'f4','wavetm1_swell':'f4','wavetm2_swell':'f4','wavedir_swell':'f4', \
                       'wavespr_swell':'f4'}
        # 'datetime':{0:'time',1:'date'}
        outshape = {'time':'time','wavehs':'time','wavetp':'time','wavetpp':'time', \
                        'wavetm':'time','wavetm1':'time','wavetm2':'time','wavedir':'time','wavespr':'time', \
                        'frequency':'freq','direction':'direc','ef2d':{0:'time',1:'freq',2:'direc'},'windspeed':'time', \
                        'winddir':'time','ustar':'time','cd':'time','ef2d_swell':{0:'time',1:'freq',2:'direc'}, \
                        'ef2d_wndsea':{0:'time',1:'freq',2:'direc'},'wavehs_wndsea':'time','wavetp_wndsea':'time', \
                        'wavetpp_wndsea':'time','wavetm_wndsea':'time','wavetm1_wndsea':'time','wavetm2_wndsea':'time', \
                        'wavedir_wndsea':'time','wavespr_wndsea':'time','wavehs_swell':'time','wavetp_swell':'time', \
                        'wavetpp_swell':'time','wavetm_swell':'time','wavetm1_swell':'time','wavetm2_swell':'time', \
                        'wavedir_swell':'time','wavespr_swell':'time'}
        for ii, stat in self.station.items():
            ef = self.ef2d[:, ii, :, :].reshape(len(self.time), len(self.freq),
                                                len(self.direc))
            wavhs = wp.calc_wvht(ef, self.freq, self.direc)
            wavtp, wavtpp = wp.calc_peak_period(ef, self.freq, self.direc)
            wavtm = wp.calc_mean_period(ef, self.freq, self.direc)
            wavtm1, wavtm2 = wp.calc_tm1_tm2(ef, self.freq, self.direc)
            wavdir, wavspr = wp.calc_wave_direction(ef, self.freq, self.direc)

            efswell, efwndsea = wp.calc_windsea_swell(ef, self.freq,
                                                      self.direc,
                                                      self.ustar[:, ii],
                                                      self.wnddir[:, ii])

            wavhs_wndsea = wp.calc_wvht(efwndsea, self.freq, self.direc)
            wavtp_wndsea, wavtpp_wndsea = wp.calc_peak_period(
                efwndsea, self.freq, self.direc)
            wavtm_wndsea = wp.calc_mean_period(efwndsea, self.freq, self.direc)
            wavtm1_wndsea, wavtm2_wndsea = wp.calc_tm1_tm2(
                efwndsea, self.freq, self.direc)
            wavdir_wndsea, wavspr_wndsea = wp.calc_wave_direction(
                efwndsea, self.freq, self.direc)

            wavhs_swell = wp.calc_wvht(efswell, self.freq, self.direc)
            wavtp_swell, wavtpp_swell = wp.calc_peak_period(
                efswell, self.freq, self.direc)
            wavtm_swell = wp.calc_mean_period(efswell, self.freq, self.direc)
            wavtm1_swell, wavtm2_swell = wp.calc_tm1_tm2(
                efswell, self.freq, self.direc)
            wavdir_swell, wavspr_swell = wp.calc_wave_direction(
                efswell, self.freq, self.direc)

            # 'datetime':self.dattime
            data = {'time':self.pytime,'wavehs':wavhs,'wavetp':wavtp,'wavetpp':wavtpp,'wavetm':wavtm,'wavetm1':wavtm1,'wavetm2':wavtm2,'wavedir':wavdir, \
                        'wavespr':wavspr,'frequency':np.array(self.freq),'direction':np.array(self.direc),'ef2d':np.array(ef),'windspeed':self.wndspd[:,ii], \
                        'winddir':self.wnddir[:,ii],'ustar':self.ustar[:,ii],'cd':self.cd[:,ii],'ef2d_swell':efswell,'ef2d_wndsea':efwndsea, \
                        'wavehs_wndsea':wavhs_wndsea,'wavetp_wndsea':wavtp_wndsea,'wavetpp_wndsea':wavtpp_wndsea,'wavetm_wndsea':wavtm_wndsea, \
                        'wavetm1_wndsea':wavtm1_wndsea,'wavetm2_wndsea':wavtm2_wndsea,'wavedir_wndsea':wavdir_wndsea,'wavespr_wndsea':wavspr_wndsea, \
                        'wavehs_swell':wavhs_swell,'wavetp_swell':wavtp_swell,'wavetpp_swell':wavtpp_swell,'wavetm_swell':wavtm_swell, \
                        'wavetm1_swell':wavtm1_swell,'wavetm2_swell':wavtm2_swell,'wavedir_swell':wavdir_swell,'wavespr_swell':wavspr_swell}
            info = {'station':stat,'longitude':self.longitude[ii],'latitude':self.latitude[ii],'outtype':outtype,'depth':self.depth[ii], \
                        'basin':basinname[basin],'outshape':outshape, \
                        'timestart':self.timestart,'timeend':self.timeend,'year':self.year,'month':self.mon}
            dd = {'info': info, 'data': data}
            self.results.append(dd)

            #        wh5.write_stat_h5(self.results[ii])
            wnc.write_stat_nc(self.results[ii])