Commit 761702bc authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP]: reorganize Makefile for tests

parent c1235797
......@@ -34,22 +34,28 @@ clean: ;
-/bin/rm -vf flist *.bin *.o *.xxx *.ps *.pdf *~
-/bin/rm -vf *.asc
# ======================================================================
# create time series
# ==================
#
# set time series parameters
# --------------------------
CPSD_NSAMPLESRAW=100000
#CPSD_NSAMPLESRAW=1000
CPSD_DT=0.1
CPSD_DUR=8640.
#CPSD_DUR=864.
# ----------------------------------------------------------------------
# create raw time series
CPSD_SIGGENOPT=-v -o -n $(CPSD_NSAMPLESRAW) -d $(CPSD_DT) -T $(CPSD_DUR) -ot bin
CPSD_AMP1=1.e-3
CPSD_AMP2=1.e-4
CPSD_AMP3=3.e-3
CPSD_AMP4=5.e-5
CPSD_AMPBG=2.
# location of plot tool
CROPOSPLOT=../croposplot.py
# ----------------------
# Several time series of normally distributed random samples with zero mean
# are computed with siggenx. To make them incoherent, each run requires its
# own specific seed value for the random number generator. We use the
# nanosecond field of the system clock.
#
CPSD_SIGGENOPT=-v -o -n $(CPSD_NSAMPLESRAW) -d $(CPSD_DT) \
-T $(CPSD_DUR) -ot bin
cpsd1raw.bin:
/bin/bash -c 'export GSL_RNG_SEED=$$(date +"%N"); \
......@@ -73,9 +79,27 @@ cpsdbgraw.bin:
siggenx 14 $@ $(CPSD_SIGGENOPT); \
echo seed: $$GSL_RNG_SEED'
# provide a time series plot to confirm incoherency
rawsig.ps: cpsd1raw.bin cpsd2raw.bin cpsd3raw.bin cpsd4raw.bin cpsdbgraw.bin
stuplox -d $@/cps -s x -i -ty bin $^
# ----------------------------------------------------------------------
# scale and filter time series
# ----------------------------
#
# The raw random sequences are adjusted to represent four sets of incoherent
# noise and one random sequence ('bg') which will be common in all final data
# files. We understand the first four as a simulation of instrumental noise
# and the bg-sequence as a representation of background ground noise to be
# common in all reacordings.
#
# set amplitudes
CPSD_AMP1=1.e-3
CPSD_AMP2=1.e-4
CPSD_AMP3=3.e-3
CPSD_AMP4=5.e-5
CPSD_AMPBG=2.
# modify white noise to channel specific frequency characteristic
cpsd1mod.bin: cpsd1raw.bin
printf "fac $(CPSD_AMP1)\nlpb 1.,2.\ndif 0\nend\n" \
......@@ -111,6 +135,13 @@ cpsd4add.bin: cpsd4addraw.bin
printf "lpb 10.,2\nend\n" \
| tidofi -type bin -Type bin -v -o -cs $@ $<
# ----------------------------------------------------------------------
# adjust time series headers
# --------------------------
#
# recorded data is expected to be taken with slightly different sampling;
# croposp is expected to be able to handle this
#
# set header fields to reasonable time an channel identifiers
CPSD_DATE=2018/12/16_14:24:16
CPSD_DATE1=$(CPSD_DATE).010980
......@@ -146,6 +177,11 @@ cpsd4.bin: cpsd4hd.bin
tijerasxx -verbose -overwrite -iformat bin -oformat bin \
$(CPSD_TOPT4) $@ $<
# ======================================================================
# analyze time series
# ===================
#
# set croposp options
CPSD_NSEGMENTS=1
CPSD_OVERLAP=0.5
CPSD_DIVISOR=100
......@@ -156,16 +192,24 @@ CPSD_OPT=--DEBUG
CPSD_OPT=
OUTPUTS=psd npsd coherency transfer phase
CPSD_SET=1 2 3
CPSD_SET=1 2 3 4
CPSD_BINFILES=$(addprefix cpsd,$(addsuffix .bin,$(CPSD_SET)))
CPSD_RAWFILES=$(addprefix cpsd,$(addsuffix mod.bin,$(CPSD_SET) bg)) \
# define string summarizing essential croposp options
# this will be included in the title of diagrams
CPSD_CROPOSP_OPT=--nsegments=$(CPSD_NSEGMENTS) \
--divisor=$(CPSD_DIVISOR) \
--padfactor=$(CPSD_PADFACTOR) \
--overlap=$(CPSD_OVERLAP) $(CPSD_LOG)
# select sets to be analyzed
# four are available, three must be used at least
CPSD_SET=1 2 3
CPSD_SET=1 2 3 4
# compile list of file names as input to croposp
CPSD_BINFILES=$(addprefix cpsd,$(addsuffix .bin,$(CPSD_SET)))
# compile list of raw files (apparent instrumental noise and seismic
# background noise separately)
CPSD_RAWFILES=$(addprefix cpsd,$(addsuffix mod.bin,$(CPSD_SET) bg)) \
# run complete analysis on the apparent seismometer output
$(addsuffix _out.xxx,$(OUTPUTS)): $(CPSD_BINFILES)
croposp $(CPSD_OPT) --verbose --overwrite --itype bin --trim \
--pattern="%I" \
......@@ -178,6 +222,8 @@ $(addsuffix _out.xxx,$(OUTPUTS)): $(CPSD_BINFILES)
--phase phase_out.xxx \
$^
# compute PSD for raw files (apparent instrumental noise and seismic
# background noise separately)
psdraw.xxx: $(CPSD_RAWFILES)
croposp $(CPSD_OPT) --verbose --overwrite --itype bin --trim \
--pattern="%F" \
......@@ -185,26 +231,52 @@ psdraw.xxx: $(CPSD_RAWFILES)
--datetolerance 0.1 \
--psd $@ $^
# compute PSD with foutra, which is used as a reference to confirm correct
# calibration of algorithms
psd%.001.asc: cpsd%.bin
foutra -v -o -type bin -ASCII=$(patsubst cpsd%.bin,psd%,$<) \
-power -rbw=0.1 -demean -detrend -logascii=0.1 -avgascii \
-nsegments=20 junk.xxx $^
# convert foutra output to the file format expected by croposplot.py
psd%foutra.xxx: psd%.001.asc
printf "# #1: foutra (reference): %s\n" $< > $@
cat $< >> $@
# ======================================================================
# display results
# ===============
#
# location of plot tool
CROPOSPLOT=../croposplot.py
# ----------------------------------------------------------------------
# reference plots
# ---------------
#
# Display PSD together with results from foutra.
#
# compile list of file names as analyzed with foutra
CPSD_REFFILES=$(addprefix psd,$(addsuffix foutra.xxx,$(CPSD_SET)))
# compile list of raw files (apparent instrumental noise and seismic
# background noise separately) analyzed with foutra
CPSD_RAWREFFILES=$(addprefix psd,$(addsuffix modfoutra.xxx,$(CPSD_SET) bg))
# display PSD of raw data (apparent instrumental noise and seismic
# background noise separately)
PSDraw.pdf: psdraw.xxx $(CPSD_RAWREFFILES)
$(CROPOSPLOT) --title="$@ \n $(CPSD_CROPOSP_OPT)" \
--titfontsize='small' -v --grid -o $@ $^
# display PSD of apparent seismometer output in comparison with foutra
# analysis
PSD.pdf: psd_out.xxx $(CPSD_REFFILES)
$(CROPOSPLOT) --title="$@ \n $(CPSD_CROPOSP_OPT)" \
--titfontsize='small' -v --grid -o $@ $^
# ----------------------------------------------------------------------
# pattern rules for quick plots
# -----------------------------
%.pdf: %_out.xxx
$(CROPOSPLOT) --title='$@ \n $(CPSD_CROPOSP_OPT)' \
--titfontsize='small' -v --grid -o $@ $<
......@@ -214,6 +286,9 @@ PSD.pdf: psd_out.xxx $(CPSD_REFFILES)
--titfontsize='small' -v --grid --nology -o \
$@ $<
# ----------------------------------------------------------------------
# previewer commands
# ------------------
%.pdp: %.pdf; evince $<; /bin/rm -fv $<
%.psp: %.ps; gv $<; /bin/rm -fv $<
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment