Example #1
0
    res.nglMaximize = True
    res.nglDraw  = False; res.nglFrame = False
    res.vpWidthF = 0.74; res.vpHeightF = 0.54
    res.tmBorderThicknessF = 10.0
    res.tmXBMajorThicknessF = 10.0; res.tmXBMinorThicknessF = res.tmXBMajorThicknessF
    res.tmYLMajorThicknessF = res.tmXBMajorThicknessF; res.tmYLMinorThicknessF = res.tmXBMajorThicknessF
    res.tmXBLabelFont = 26; res.tmYLLabelFont = res.tmXBLabelFont
    res.tmXBLabelFontHeightF = 0.016; res.tmYLLabelFontHeightF = res.tmXBLabelFontHeightF
    res.tiXAxisFontHeightF = 0.020; res.tiYAxisFontHeightF = res.tiXAxisFontHeightF
    res.tiMainFont = 25
    LeftString = ""
    print("\033[44m{} \033[0m".format(LeftString))
    return wks, res, LeftString

#--------------------------------------------------------------------
start_time = cpu_time()
#initialize parameters
samplerate = 250 # Hz, get 250 samples per sec. (or kilometer)
N = 512 # datalength, total samples
#print(nextpow2(1023))
zero_padd_log = True
#--------------------------------------------------------------------
sinfreq = 10 # Hz, frequency of the signal (or wavenumber km-1)
#generate a sine singals
t = np.arange(1,N+1)/float(samplerate); #print(t)
sig = np.sin(2.*np.pi*sinfreq*t); #print(sig)

""" Spectral analysis (FFT) """
#the max. resolved frequency is half sampling rate
if zero_padd_log:
   #Zero-padding could make it faster 
import sys
sys.path.append("/home/mlhchen/GIT/WRF_plot_tools")
from package import wrf_tools, colorbar_tables  #local function
from time import time as cpu_time
import os
import copy
import numpy as np
import pandas as pd
import Ngl

start_time = cpu_time()
undef = -999.  #9.96920996839e+36
ny = 4624
nx = 6898
smooth_log = True
rain_gauge_mark_log = 1
radar_mark_log = 1
precip_mark_log = 0
precip2_mark_log = 0


def read_bin():
    ff = r'Northen_Taiwan.bin'
    print("\033[44mReading file: {}\033[0m".format(ff))
    dt = np.dtype((np.float64, (ny, nx)))
    lon = np.zeros(shape=(ny, nx), dtype=np.float64)
    lat = np.zeros(shape=(ny, nx), dtype=np.float64)
    hgt = np.zeros(shape=(ny, nx), dtype=np.float64)
    with open(ff, "rb") as f:
        lon = np.fromfile(f, dt, 1)[0]
        lat = np.fromfile(f, dt, 1)[0]