Ejemplo n.º 1
0
def main_arg(x,y,grid_count):  
    print grid_count
    ofac = 4

    #average dt of entire time series
    diffs = [x[i+1]-x[i] for i in range(len(x)-1)]  
    avgdt = np.average(diffs)

    #make time start from 0    
    x_from0 = modules.phase_start_correct(x)

    periods,mag,ph,fr,fi,amp_corr = modules.take_lomb(x_from0,y,ofac,avgdt)

    #get mean of values
    mean_array = np.average(y)

    #correct magnitude and phase for spectral leakage 
    zoomfact = 1000
    half_annual_mag,half_annual_phase = modules.periodic_interp(fr,fi,zoomfact,periods,365.25/2.,len(y),amp_corr)
    annual_mag,annual_phase = modules.periodic_interp(fr,fi,zoomfact,periods,365.25,len(y),amp_corr)

    #correct for phase shift as data starts in Oct 2004 
    n_off = 273.25
    
    if n_off > 365.25/2:
        n_off = n_off-(365.25/2)
    offset = ((np.pi*2)/(365.25/2))*n_off
    half_annual_phase = half_annual_phase + offset
    if half_annual_phase > np.pi:
        half_annual_phase = -np.pi + (half_annual_phase - np.pi)

    n_off = 273.25
    offset = ((np.pi*2)/(365.25))*n_off
    annual_phase = annual_phase + offset
    if annual_phase > np.pi:
        annual_phase = -np.pi + (annual_phase - np.pi)

    #convert phase to time
    half_annual_phase = modules.convert_phase_units_actual_single(half_annual_phase,6)
    annual_phase = modules.convert_phase_units_actual_single(annual_phase,12)
    
    #np.save('mags_phases/mag_spectrums/%i'%(grid_count),mag)
    #np.save('mags_phases/phase_spectrums/%i'%(grid_count),ph)
    #np.save('mags_phases/periods',periods)
    return (half_annual_mag,half_annual_phase,annual_mag,annual_phase,mean_array)
Ejemplo n.º 2
0
def run_LSP(valid_times, vals, start_point, end_point, x, time_diff):

    vals = vals[start_point:end_point]
    valid_times = valid_times[start_point:end_point]

    if len(valid_times) > 0:

        #change times to go from 0 - for accurate phase
        first_time = valid_times[0]
        valid_times = valid_times - first_time

        #window
        window = np.hamming(len(vals))
        mean = np.mean(vals)
        vals = vals - mean
        vals = vals * window

        NOUT = 0.5 * 4 * 1 * len(vals)
        NOUT = int(NOUT)

        #take lomb
        fa, fb, mag, ph = lomb_phase.lomb(valid_times, vals, NOUT)
        periods = 1. / fa
        amp_corr = 1. / (sum(window) / len(window))
        mag = mag * amp_corr

        #calculations for mags and phases of key periods

        closest_daily_period_index = min(
            range(len(periods)), key=lambda i: abs(periods[i] - daily_period))

        daily_mag = mag[closest_daily_period_index]
        daily_phase = ph[closest_daily_period_index]

        #adjust daily_phase to solar time
        correction_f = ((2 * np.pi) / 24) * time_diff
        daily_phase = daily_phase + (correction_f)
        if daily_phase < -np.pi:
            diff = np.abs(daily_phase) - np.pi
            daily_phase = np.pi - diff
        if daily_phase > np.pi:
            diff = np.abs(daily_phase) - np.pi
            daily_phase = -np.pi + diff

        #convert phase to hours
        daily_phase = modules.convert_phase_units_actual_single(
            daily_phase, 24)

    else:
        print 'nan'
        daily_mag = float('NaN')
        daily_phase = float('NaN')

    return (daily_mag, daily_phase, x)
Ejemplo n.º 3
0
def run_LSP(model_data, x):

    print obs_refs[x]

    vals = model_data

    #check obs vals are valid
    valid = vals >= 0
    vals = vals[valid]
    model_time_val = model_time[valid]
    model_date_val = model_date[valid]

    full_times = modules.date_process(model_date, model_time, start_year)
    if timeres == 'M':
        full_times_year = full_times[:12]
    else:
        full_times_year = full_times[:8766]
    full_times_day = full_times[:24]

    valid_times = modules.date_process(model_date_val, model_time_val,
                                       start_year)

    site_lon = obs_lons[x]

    #convert site_lon to 0 to 360 degs
    if site_lon < 0:
        site_lon = 360 - np.abs(site_lon)

    #transform from UTC time to solar time
    sun_time = lon_step_time * site_lon
    time_diff = sun_time - 0
    if time_diff > 12:
        time_diff = time_diff - 24

    #make time start from 0
    valid_times_from0 = modules.phase_start_correct(valid_times)

    periodic_periods = [
        1. / 4., 1. / 3., 1. / 2., 1., 365.25 / 4., 365.25 / 3., 365.25 / 2.,
        365.25
    ]
    periods, mag, ph, fr, fi = modules.take_lomb_spec(
        valid_times_from0, vals, w=True, key_periods=periodic_periods)

    #get mean of values
    mean_array = np.average(vals)

    #correct all phases for start point (not actually being from 0 - just corrected to be)
    ph = modules.phase_start_point_correct_all(periodic_periods, ph,
                                               valid_times)

    key_diurnal_periods = [1. / 4., 1. / 3., 1. / 2., 1.]
    key_seasonal_periods = [365.25 / 4., 365.25 / 3., 365.25 / 2., 365.25]

    diurnal_mags = mag[:4]
    seasonal_mags = mag[4:]
    seasonal_phs = ph[4:]

    #get individual mags and phases
    daily_h3_mag = mag[0]
    daily_h2_mag = mag[1]
    daily_h1_mag = mag[2]
    orig_daily_mag = mag[3]
    daily_h3_ph = ph[0]
    daily_h2_ph = ph[1]
    daily_h1_ph = ph[2]
    orig_daily_ph = ph[3]

    seasonal_h3_mag = mag[4]
    seasonal_h2_mag = mag[5]
    seasonal_h1_mag = mag[6]
    annual_mag = mag[7]
    seasonal_h3_ph = ph[4]
    seasonal_h2_ph = ph[5]
    seasonal_h1_ph = ph[6]
    annual_ph = ph[7]

    #convert sub diurnal phases from UTC to solar time
    daily_h3_ph = modules.solar_time_phase_corrector(daily_h3_ph, 6, time_diff)
    daily_h2_ph = modules.solar_time_phase_corrector(daily_h2_ph, 24. / 3.,
                                                     time_diff)
    daily_h1_ph = modules.solar_time_phase_corrector(daily_h1_ph, 12,
                                                     time_diff)
    orig_daily_ph = modules.solar_time_phase_corrector(orig_daily_ph, 24,
                                                       time_diff)
    diurnal_phs = [daily_h3_ph, daily_h2_ph, daily_h1_ph, orig_daily_ph]

    #convolve annual cycle and harmonics to seasonal waveform for 1 year
    seasonal_mag, seasonal_min_ph, seasonal_max_ph, seasonal_waveform, seasonal_ff = modules.period_convolution(
        key_seasonal_periods, full_times_year, seasonal_mags, seasonal_phs,
        mean_array)

    #convolve diurnal cycle and harmonics to diurnal waveform for 1 day
    diurnal_mag, diurnal_min_ph, diurnal_max_ph, diurnal_waveform, diurnal_ff = modules.period_convolution(
        key_diurnal_periods, full_times_day, diurnal_mags, diurnal_phs,
        mean_array)

    #convolve all
    full_mag, full_min_ph, full_max_ph, full_waveform, full_ff = modules.period_convolution(
        periodic_periods, full_times, mag, ph, mean_array)

    #convert phase to time
    daily_h3_ph = modules.convert_phase_units_actual_single(daily_h3_ph, 6.)
    daily_h2_ph = modules.convert_phase_units_actual_single(
        daily_h2_ph, 24. / 3.)
    daily_h1_ph = modules.convert_phase_units_actual_single(daily_h1_ph, 12.)
    orig_daily_ph = modules.convert_phase_units_actual_single(
        orig_daily_ph, 24.)
    diurnal_min_ph = modules.convert_phase_units_actual_single(
        diurnal_min_ph, 24.)
    diurnal_max_ph = modules.convert_phase_units_actual_single(
        diurnal_max_ph, 24.)
    seasonal_h3_ph = modules.convert_phase_units_actual_single(
        seasonal_h3_ph, 3.)
    seasonal_h2_ph = modules.convert_phase_units_actual_single(
        seasonal_h2_ph, 4.)
    seasonal_h1_ph = modules.convert_phase_units_actual_single(
        seasonal_h1_ph, 6.)
    annual_ph = modules.convert_phase_units_actual_single(annual_ph, 12.)
    seasonal_min_ph = modules.convert_phase_units_actual_single(
        seasonal_min_ph, 12.)
    seasonal_max_ph = modules.convert_phase_units_actual_single(
        seasonal_max_ph, 12.)

    return (x, daily_h3_mag, daily_h3_ph, daily_h2_mag, daily_h2_ph,
            daily_h1_mag, daily_h1_ph, orig_daily_mag, orig_daily_ph,
            diurnal_mag, diurnal_min_ph, diurnal_max_ph, seasonal_h3_mag,
            seasonal_h3_ph, seasonal_h2_mag, seasonal_h2_ph, seasonal_h1_mag,
            seasonal_h1_ph, annual_mag, annual_ph, seasonal_mag,
            seasonal_min_ph, seasonal_max_ph, mean_array, diurnal_waveform,
            seasonal_waveform, full_waveform)
Ejemplo n.º 4
0
def run_LSP(obs_time,site_lon,x):

    data_valid = True

    #print 'lev %s'%(x)
    
    full_times_year = np.arange(0,365,1.)
    
    #check obs vals are valid
    valid = vals >= 0
    vals = vals[valid]
    valid_times = obs_time[valid]

    #if length of vals is zero then class as invalid immediately
    if len(vals) == 0:
        data_valid = False
    else:
        #test if there if data is valid to process at each height for each site
        #data should not have gaps > 1 year or 
        time_gaps = np.diff(valid_times)                
        inv_count = 0
        max_count = round(n_years/2.)
        for i in time_gaps:
            if i > 90:
                inv_count+=1
                if inv_count >= max_count:
                    data_valid = False
                    print 'Persisent Data gap > 3 months'
                    break
            if i > 365:
                    data_valid = False
                    print 'Data gap > 1 Year'
                    break

    if data_valid == True:
    
        #convert site_lon to 0 to 360 degs
        if site_lon < 0:
            site_lon = 360-np.abs(site_lon)

        #make time start from 0    
        valid_times_from0 = modules.phase_start_correct(valid_times)

        periodic_periods = [365.25/4.,365.25/3.,365.25/2.,365.25]
        periods,mag,ph,fr,fi = modules.take_lomb_spec(valid_times_from0,vals,w=True,key_periods=periodic_periods)

        #get mean of values
        mean_array = np.average(vals)
    
        #correct all phases for start point (not actually being from 0 - just corrected to be)
        ph = modules.phase_start_point_correct_all(periodic_periods,ph,valid_times)

        key_seasonal_periods = [365.25/4.,365.25/3.,365.25/2.,365.25]

        seasonal_mags = mag[:]
        seasonal_phs = ph[:]

        seasonal_h3_mag = mag[0]
        seasonal_h2_mag = mag[1]
        seasonal_h1_mag = mag[2]
        annual_mag = mag[3]
        seasonal_h3_ph = ph[0]
        seasonal_h2_ph = ph[1]
        seasonal_h1_ph = ph[2]
        annual_ph = ph[3]

        #convolve annual cycle and harmonics to seasonal waveform for 1 year
        seasonal_mag,seasonal_min_ph,seasonal_max_ph,seasonal_waveform,seasonal_ff = modules.period_convolution(key_seasonal_periods,full_times_year,seasonal_mags,seasonal_phs,mean_array)
        
        #convert phase to time
        seasonal_h3_ph = modules.convert_phase_units_actual_single(seasonal_h3_ph,3.)
        seasonal_h2_ph = modules.convert_phase_units_actual_single(seasonal_h2_ph,4.)
        seasonal_h1_ph = modules.convert_phase_units_actual_single(seasonal_h1_ph,6.)
        annual_ph = modules.convert_phase_units_actual_single(annual_ph,12.)
        seasonal_min_ph = modules.convert_phase_units_actual_single(seasonal_min_ph,12.)
        seasonal_max_ph = modules.convert_phase_units_actual_single(seasonal_max_ph,12.)

    else:
        seasonal_h3_mag = -99999
        seasonal_h2_mag = -99999
        seasonal_h1_mag = -99999
        annual_mag = -99999
        seasonal_mag = -99999
        
        seasonal_h3_ph = -99999
        seasonal_h2_ph = -99999
        seasonal_h1_ph = -99999
        annual_ph = -99999
        seasonal_max_ph = -99999
        seasonal_min_ph = -99999

        seasonal_waveform = np.array([-99999]*len(full_times_year))

        mean_array = -99999
    
    return x,seasonal_h3_mag,seasonal_h3_ph,seasonal_h2_mag,seasonal_h2_ph,seasonal_h1_mag,seasonal_h1_ph,annual_mag,annual_ph,seasonal_mag,seasonal_max_ph,seasonal_min_ph,seasonal_waveform,mean_array
def run_LSP(vals, x):

    print obs_refs[x]
    
    #check obs vals are valid
    valid = vals >= 0
    vals = vals[valid]
    valid_times = obs_ref_time[valid]

    if timeres == 'H':
        full_times_year = obs_ref_time[:8766]
    elif timeres == 'D':
        full_times_year = obs_ref_time[:365]
    elif timeres == 'M':
        full_times_year = obs_ref_time[:12]
    full_times_day = obs_ref_time[:24] 
      
    site_lon = obs_lons[x]

    #convert site_lon to 0 to 360 degs
    if site_lon < 0:
        site_lon = 360-np.abs(site_lon)
    
    #transform from UTC time to solar time 
    sun_time = lon_step_time*site_lon
    time_diff = sun_time - 0
    if time_diff > 12:
        time_diff = time_diff-24

    #make time start from 0    
    valid_times_from0 = modules.phase_start_correct(valid_times)

    print valid_times_from0

    periodic_periods = [1./4.,1./3.,1./2.,1.,365.25/4.,365.25/3.,365.25/2.,365.25]
    periods,mag,ph,fr,fi = modules.take_lomb_spec(valid_times_from0,vals,w=True,key_periods=periodic_periods)
    
    #get mean of values
    mean_array = np.average(vals)
    
    #correct all phases for start point (not actually being from 0 - just corrected to be)
    ph = modules.phase_start_point_correct_all(periodic_periods,ph,valid_times)

    key_diurnal_periods = [1./4.,1./3.,1./2.,1.]
    key_seasonal_periods = [365.25/4.,365.25/3.,365.25/2.,365.25]

    diurnal_mags = mag[:4]
    seasonal_mags = mag[4:]
    seasonal_phs = ph[4:]

    #get individual mags and phases
    daily_h3_mag = mag[0]
    daily_h2_mag = mag[1]
    daily_h1_mag = mag[2]
    orig_daily_mag = mag[3]
    daily_h3_ph = ph[0]
    daily_h2_ph = ph[1]
    daily_h1_ph = ph[2]
    orig_daily_ph = ph[3]
    
    seasonal_h3_mag = mag[4]
    seasonal_h2_mag = mag[5]
    seasonal_h1_mag = mag[6]
    annual_mag = mag[7]
    seasonal_h3_ph = ph[4]
    seasonal_h2_ph = ph[5]
    seasonal_h1_ph = ph[6]
    annual_ph = ph[7]

    #convert sub diurnal phases from UTC to solar time
    daily_h3_ph = modules.solar_time_phase_corrector(daily_h3_ph,6,time_diff)
    daily_h2_ph = modules.solar_time_phase_corrector(daily_h2_ph,24./3.,time_diff)
    daily_h1_ph = modules.solar_time_phase_corrector(daily_h1_ph,12,time_diff)
    orig_daily_ph = modules.solar_time_phase_corrector(orig_daily_ph,24,time_diff)
    diurnal_phs = [daily_h3_ph,daily_h2_ph,daily_h1_ph,orig_daily_ph]

    #convolve annual cycle and harmonics to seasonal waveform for 1 year
    seasonal_mag,seasonal_min_ph,seasonal_max_ph,seasonal_waveform,seasonal_ff = modules.period_convolution(key_seasonal_periods,full_times_year,seasonal_mags,seasonal_phs,mean_array)

    #convolve diurnal cycle and harmonics to diurnal waveform for 1 day
    diurnal_mag,diurnal_min_ph,diurnal_max_ph,diurnal_waveform,diurnal_ff = modules.period_convolution(key_diurnal_periods,full_times_day,diurnal_mags,diurnal_phs,mean_array)
    
    #convolve all 
    full_mag,full_min_ph,full_max_ph,full_waveform,full_ff = modules.period_convolution(periodic_periods,obs_ref_time,mag,ph,mean_array)

    #convert phase to time
    daily_h3_ph = modules.convert_phase_units_actual_single(daily_h3_ph,6.)
    daily_h2_ph = modules.convert_phase_units_actual_single(daily_h2_ph,24./3.)
    daily_h1_ph = modules.convert_phase_units_actual_single(daily_h1_ph,12.)
    orig_daily_ph = modules.convert_phase_units_actual_single(orig_daily_ph,24.)
    diurnal_min_ph = modules.convert_phase_units_actual_single(diurnal_min_ph,24.)
    diurnal_max_ph = modules.convert_phase_units_actual_single(diurnal_max_ph,24.)
    seasonal_h3_ph = modules.convert_phase_units_actual_single(seasonal_h3_ph,3.)
    seasonal_h2_ph = modules.convert_phase_units_actual_single(seasonal_h2_ph,4.)
    seasonal_h1_ph = modules.convert_phase_units_actual_single(seasonal_h1_ph,6.)
    annual_ph = modules.convert_phase_units_actual_single(annual_ph,12.)
    seasonal_min_ph = modules.convert_phase_units_actual_single(seasonal_min_ph,12.)
    seasonal_max_ph = modules.convert_phase_units_actual_single(seasonal_max_ph,12.)

    return (x,daily_h3_mag,daily_h3_ph,daily_h2_mag,daily_h2_ph,daily_h1_mag,daily_h1_ph,orig_daily_mag,orig_daily_ph,diurnal_mag,diurnal_min_ph,diurnal_max_ph,seasonal_h3_mag,seasonal_h3_ph,seasonal_h2_mag,seasonal_h2_ph,seasonal_h1_mag,seasonal_h1_ph,annual_mag,annual_ph,seasonal_mag,seasonal_min_ph,seasonal_max_ph,mean_array,diurnal_waveform,seasonal_waveform,full_waveform,diurnal_ff,seasonal_ff,full_ff)
Ejemplo n.º 6
0
daily_model_mag,daily_model_phase = modules.periodic_interp(model_fr,model_fi,zoomfact,model_periods,1.,len(model_var),model_amp_corr)
ha_obs_mag,ha_obs_phase = modules.periodic_interp(obs_fr,obs_fi,zoomfact,obs_periods,(365.25/2.),len(obs_var),obs_amp_corr)
ha_model_mag,ha_model_phase = modules.periodic_interp(model_fr,model_fi,zoomfact,model_periods,(365.25/2.),len(model_var),model_amp_corr)
annual_obs_mag,annual_obs_phase = modules.periodic_interp(obs_fr,obs_fi,zoomfact,obs_periods,365.25,len(obs_var),obs_amp_corr)
annual_model_mag,annual_model_phase = modules.periodic_interp(model_fr,model_fi,zoomfact,model_periods,365.25,len(model_var),model_amp_corr)

#correct for phase shift from sites where raw times do not start from 0
daily_obs_phase = modules.phase_start_point_correct(1.,daily_obs_phase,obs_time)
daily_model_phase = modules.phase_start_point_correct(1.,daily_model_phase,model_time)
ha_obs_phase = modules.phase_start_point_correct((365.25/2.),ha_obs_phase,obs_time)
ha_model_phase = modules.phase_start_point_correct((365.25/2.),ha_model_phase,model_time)
annual_obs_phase = modules.phase_start_point_correct(365.25,annual_obs_phase,obs_time)
annual_model_phase = modules.phase_start_point_correct(365.25,annual_model_phase,model_time)

#convert phase to time
daily_obs_phase = modules.convert_phase_units_actual_single(daily_obs_phase,24)
daily_model_phase = modules.convert_phase_units_actual_single(daily_model_phase,24)
ha_obs_phase = modules.convert_phase_units_actual_single(ha_obs_phase,6)
ha_model_phase = modules.convert_phase_units_actual_single(ha_model_phase,6)
annual_obs_phase = modules.convert_phase_units_actual_single(annual_obs_phase,12)
annual_model_phase = modules.convert_phase_units_actual_single(annual_model_phase,12)



#Maske daily phase SolaR time from UTC
daily_obs_phase = daily_obs_phase + time_diff
daily_model_phase = daily_model_phase + time_diff

if daily_obs_phase >= 24:
	daily_obs_phase = daily_obs_phase-24
if daily_obs_phase < 0:
Ejemplo n.º 7
0
        periods = 1. / fa
        amp_corr = 1. / (sum(window) / len(window))
        mag = mag * amp_corr

        closest_daily_period_index = min(
            range(len(periods)), key=lambda i: abs(periods[i] - daily_period))

        daily_mag = mag[closest_daily_period_index]
        daily_phase = ph[closest_daily_period_index]

        print np.min(ph)
        print np.max(ph)
        #print vals
        print 'daily phase = ', daily_phase

        print 'daily phase = ', modules.convert_phase_units_actual_single(
            daily_phase, 24)

        #daily_phase = modules.correct_select_daily_phase_actual_single(daily_phase,lon_c,lat_c,lon_e,lat_e, site_lon)

        #daily_phase = modules.convert_phase_units_actual_single(daily_phase,24)

        print 'sun time =', sun_time
        print 'time diff = ', time_diff
        #adjust daily_phase to solar time
        correction_f = ((2 * np.pi) / 24) * time_diff
        daily_phase = daily_phase + (correction_f)
        if daily_phase < -np.pi:
            diff = np.abs(daily_phase) - np.pi
            daily_phase = np.pi - diff
        if daily_phase > np.pi:
            diff = np.abs(daily_phase) - np.pi
Ejemplo n.º 8
0
#transform from UTC time to solar time
sun_time = lon_step_time * obs_lon
time_diff = sun_time - 0
if time_diff > 12:
    time_diff = time_diff - 24

#convert daily phase from UTC to solar time
daily_phase = daily_phase + ((pi2 / 24.) * time_diff)
if daily_phase >= np.pi:
    daily_phase = -np.pi + (daily_phase - np.pi)
if daily_phase < -np.pi:
    daily_phase = np.pi - (np.abs(daily_phase) - np.pi)

#convert phase to time
daily_phase_time = modules.convert_phase_units_actual_single(daily_phase, 24)
ha_phase_time = modules.convert_phase_units_actual_single(ha_phase, 6)
annual_phase_time = modules.convert_phase_units_actual_single(annual_phase, 12)

daily_wave = daily_amp * (np.cos((pi2 * obs_times_full / 1.) - (daily_phase)))
ha_wave = ha_amp * (np.cos((pi2 * obs_times_full / (365.25 / 2.)) -
                           (ha_phase)))
annual_wave = annual_amp * (np.cos((pi2 * obs_times_full / 365.25) -
                                   (annual_phase)))

big_wave = daily_wave + ha_wave + annual_wave
big_wave = big_wave + obs_ave

daily_wave = daily_wave + obs_ave
ha_wave = ha_wave + obs_ave
annual_wave = annual_wave + obs_ave
Ejemplo n.º 9
0
def main_arg(x, y, grid_count):
    print grid_count
    ofac = 4

    orig_len = len(y)
    print np.min(y)
    #cut valid data
    x = x[~np.isnan(y)]
    y = y[~np.isnan(y)]

    if len(y) > (orig_len / 2):
        #average dt of entire time series
        diffs = [x[i + 1] - x[i] for i in range(len(x) - 1)]
        avgdt = np.average(diffs)

        #make time start from 0
        x_from0 = modules.phase_start_correct(x)

        periods, mag, ph, fr, fi, amp_corr = modules.take_lomb(
            x_from0, y, ofac, avgdt)

        #get mean of values
        mean_array = np.average(y)

        #correct magnitude and phase for spectral leakage
        zoomfact = 1000
        half_annual_mag, half_annual_phase = modules.periodic_interp(
            fr, fi, zoomfact, periods, 365.25 / 2., len(y), amp_corr)
        annual_mag, annual_phase = modules.periodic_interp(
            fr, fi, zoomfact, periods, 365.25, len(y), amp_corr)

        #correct for phase shift as data starts in Oct 2004
        n_off = 273.25

        if n_off > 365.25 / 2:
            n_off = n_off - (365.25 / 2)
        offset = ((np.pi * 2) / (365.25 / 2)) * n_off
        half_annual_phase = half_annual_phase + offset
        if half_annual_phase > np.pi:
            half_annual_phase = -np.pi + (half_annual_phase - np.pi)

        n_off = 273.25
        offset = ((np.pi * 2) / (365.25)) * n_off
        annual_phase = annual_phase + offset
        if annual_phase > np.pi:
            annual_phase = -np.pi + (annual_phase - np.pi)

        #convert phase to time
        half_annual_phase = modules.convert_phase_units_actual_single(
            half_annual_phase, 6)
        annual_phase = modules.convert_phase_units_actual_single(
            annual_phase, 12)

    else:
        half_annual_mag = -99999
        half_annual_phase = -99999
        annual_mag = -99999
        annual_phase = -99999
        mean_array = -99999

    #np.save('mags_phases/mag_spectrums/%i'%(grid_count),mag)
    #np.save('mags_phases/phase_spectrums/%i'%(grid_count),ph)
    #np.save('mags_phases/periods',periods)
    return (half_annual_mag, half_annual_phase, annual_mag, annual_phase,
            mean_array)
Ejemplo n.º 10
0
ax2.xaxis.set_major_formatter(dt.DateFormatter('%d/%m/%Y'))
ax2.plot(obs_datetimes, obs_var, color='black', alpha=0.3)
ax2.plot(model_datetimes, model_var, color='red', alpha=0.3)
ax2.plot(model_datetimes,
         obs_wave,
         color='black',
         label='Obs. Sinusoidal Waveform',
         linewidth=2)
ax2.plot(model_datetimes,
         model_wave,
         color='red',
         label='GEOS 2x2.5 Sinusoidal Waveform',
         linewidth=2)

#convert phase to time
obs_phase = modules.convert_phase_units_actual_single(obs_annual_phase, 12)
model_phase = modules.convert_phase_units_actual_single(model_annual_phase, 12)

print obs_phase
print model_phase

ax2.grid(True)
leg = ax2.legend(loc=1, prop={'size': 21})
leg.get_frame().set_alpha(0.4)

ax2.set_xlabel('Time', fontsize=21)
ax2.set_ylabel('Concentration (ppb)', fontsize=21)
#ax.set_title(r'Time Series of Surface $O_3$ at %s, for Obs. & Model'%(site),fontsize=18)
ax.tick_params(axis='both', which='major', labelsize=18)
ax2.tick_params(axis='both', which='major', labelsize=18)
#for tick in ax.get_xaxis().get_major_ticks():