R Procedures for MLFD Beetle Analysis
Input files are at Tables
*.r programs are at R-Code/mlfd
format_xy.r
Creates inpiut for generate.aml by re-arainging xy co-ordinaes into the format desired by generate.
This was used for vector generation in arc and used the trig* files in Tables
R was usre to produce plots for:
Aspect, Slope and Elevation:
read.r
Reads in all the necesary dat for the bellow scipts including table-new*, mpb*.table, suscep* and pine* files form Tables
mpb.r
This script produces the slope, aspect, and elevatin graphs for mpb*.table files.
It has it's own rad command. In order to create the graphs for various
% intencitis of mpb the extention must be changed in the file.
hist.r
This script produces all the histograms for new,
suscep, and pine, and their % intencities. It depends on read.r
being run first.
aspect.r, slope.r and elev.r
These three are sections of hist.r and plot for new*.table data only.
Winds:
Formating of Files:
The original station files were formated using a series of regular expressions to alter the date structure:
cat mof-162-houston.txt |sed -r s/\(162\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-162-houston.formated
cat mof-161-Grassy_P.txt |sed -r s/\(161\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-161-Grassy_P.formated
cat mof-169-u_fulton.txt |sed -r s/\(169\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-169-u_fulton.formated
cat mof-170-e_ootsa.txt |sed -r s/\(170\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-170-e_ootsa.formated
cat mof-171-leo_ck.txt |sed -r s/\(171\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-171-leo_ck.formated
cat mof-173-n_babine.txt |sed -r s/\(173\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-173-n_babine.formated
cat mof-178-peden.txt |sed -r s/\(178\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-178-peden.formated
cat mof-179-nadina.txt |sed -r s/\(179\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-179-nadina.formated
cat mof-180-mcbride_lk.txt |sed -r s/\(180\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-180-mcbride_lk.formated
cat mof-181-burns_lk.txt |sed -r s/\(181\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-181-burns_lk.formated
cat mof-182-ganokwa.txt |sed -r s/\(182\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-182-ganokwa.formated
cat mof-428-kispiox.txt |sed -r s/\(428\).\(....\)\(..\)\(..\)/\\1\\t\\2\\t\\3\\t\\4\\t/>mof-428-kispiox.formated
cat houston.dat |sed -r s/\(.\)\\/\(..\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>houston.formated
cat houston.formated |sed -r s/\(.\)\\/\(.\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>houston.formated
cat burns.dat |sed -r s/\(.\)\\/\(..\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>burns.formated
cat burns.formated |sed -r s/\(.\)\\/\(.\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>burns.formated
cat smithers.dat |sed -r s/\(.\)\\/\(..\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>smithers.formated
cat smithers.formated |sed -r s/\(.\)\\/\(.\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>smithers.formated
cat telkwa.dat |sed -r s/\(.\)\\/\(..\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>telkwa.formated
cat telkwa.formated |sed -r s/\(.\)\\/\(.\)\\/\(..\)/\\3\\t\\1\\t\\2\\t/>telkwa.formated
cat houston.formated |sed -r s/\\:/\\./>houston.formated
cat smithers.formated |sed -r s/\\:/\\./>smithers.formated
cat telkwa.formated |sed -r s/\\:/\\./>telkwa.formated
cat burns.formated |sed -r s/\\:/\\./>burns.formated
Furthermore, the first line of the file containing header
information was manually deleted and in the case of MWLAP files, the end
of the file not corresponding to a full day was removed. The resultant files are named statin.formated.
Due to quality contrile issues the files were checked for consistancy
in wind speed and direction designations in R. The function:
stn_winds_qc_function.r (See comments within script for details.)
was used to create the statin.formated.qc files using
stn_wind_qc.r
Files with the extention .mean give the results of the below plot function in text form.
All formated files are at:
formated_stn
Graphs:
Station wind trends were graphed using the wind.plot function which is loaded by runing the wind.plot_function.r script
In R:
>source(file="wind.plot_function.r")
>wind.plot(Station, FILE, type=1)
eg.
>wind.plot("Grassy_P","formated_stn/mof-161-Grassy_P.formated.qc",type=1)
In order to run all stations at once, use stn_wind_plots.r
This function also creates a file for Day 1, Day 2, Day 3 and all Days
containing the mean wind speed and direction values according to:
"hr","scalorM","vectorM","cons","dirMean" in the formated_stn dirctory.
To produce a tile of the four graphs for each day use the following scripts in the same fashion as the above:
wind.plot_function4_eps.r
wind.plot_function4_jpg.r
stn_wind_plots4.r
NOTE: Since the above two functions
use the same function name (wind.plot4) you must re-run the function to
switch between jpg and eps. At the moment the eps function
creates a 2x2 matrix while the jpg function creates a 1x4 matrix.
Unlike the wind.plot functiona bove, these two variations DO NOT create
an output file of the meand speeds and directions.
Specific Regions: