Skip to content

Commit

Permalink
Added comments to more files
Browse files Browse the repository at this point in the history
  • Loading branch information
natgeo-wong committed Jul 16, 2019
1 parent 7bfe372 commit f0fac7c
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 183 deletions.
49 changes: 38 additions & 11 deletions EQ_create_print.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
function EQFile = EQ_create_print (EQtype,EQID,EQdim,EQgeom,EQpos,EQslip,EQinv)
function EQFile = EQ_create_print (type,ID,dim,geom,pos,slip,inv)

% EQ_create_print.m
% EQ Function that creates and prints to .eq files
% Nathanael Wong Zhixin, Feng Lujia
%
% This function is created for the purpose of printing the initial input
% information into .eq files, to be read and used for GTdef modelling
%
% INPUT: Earthquake event information
%
% OUTPUT:
% -- EQFile : name of .eq file created
%
% FORMAT OF CALL: EQ_create_print (type,ID,dim,geom,pos,slip,inv)
%
% OVERVIEW:
% 1) This function creates and prints data to a .eq file
%
% 2) The name of the .eq file is exported to the parent script
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CREATE FILE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

EQFile = EQ_create_printFile (EQtype,EQID,EQpos,EQslip);
fEQ = fopen (EQFile,'w');
EQFile = EQ_create_printFile(type,ID,pos,slip); fEQ = fopen(EQFile,'w');

EQ_create_printHead (fEQ,EQID);
EQ_create_printType (fEQ,EQtype);
EQ_create_printXYZ (fEQ,EQpos);
EQ_create_printDGeo (fEQ,EQdim,EQgeom);
EQ_create_printSlip (fEQ,EQslip);
EQ_create_printInv0 (fEQ,EQinv.O);
EQ_create_printInvX (fEQ,EQinv.X);
EQ_create_printInvN (fEQ,EQinv.N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PRINT DETAILS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

EQ_create_printHead(fEQ,ID);
EQ_create_printType(fEQ,type);
EQ_create_printXYZ (fEQ,pos);
EQ_create_printDGeo(fEQ,dim,geom);
EQ_create_printSlip(fEQ,slip);
EQ_create_printInv0(fEQ,inv.O);
EQ_create_printInvX(fEQ,inv.X);
EQ_create_printInvN(fEQ,inv.N);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLOSE FILE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fclose (fEQ);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end
34 changes: 31 additions & 3 deletions EQ_create_printDGeo.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
function EQ_create_printDGeo (fEQ,EQdim,EQgeom)
function EQ_create_printDGeo (fEQ,dim,geom)

% EQ_create_printDGeo.m
% EQ Function that print the event geometry to .eq
% Nathanael Wong Zhixin, Feng Lujia
%
% This function is created for the purpose of printing the dimensions and
% geometryinformation into .eq files, to be read and used in GTdef
%
% INPUT:
% -- fEQ : file name
% -- dim : dimension information
% -- geom : geometry information
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printDGeo (fEQ,dim,geom)
%
% OVERVIEW:
% 1) This function prints the event dimensions and geometry
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PRINT HEADER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fprintf (fEQ, '# DGeo Len Wid Area');
fprintf (fEQ, ' ');
fprintf (fEQ, 'Str Dip\n');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PRINT UNITS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fprintf (fEQ, '# (m) (m) (m^2)');
fprintf (fEQ, ' ');
fprintf (fEQ, '(d) (d)\n');

fprintf (fEQ, ' DGeo %-6.0f %-6.0f %-e', EQdim);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PRINT DETAILS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fprintf (fEQ, ' DGeo %-6.0f %-6.0f %-e', dim);
fprintf (fEQ, ' ');
fprintf (fEQ, '%-5.1f %-4.1f\n\n', EQgeom);
fprintf (fEQ, '%-5.1f %-4.1f\n\n', geom);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end
34 changes: 28 additions & 6 deletions EQ_create_printFile.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
function EQFile = EQ_create_printFile (EQtype,EQID,EQpos,EQslip)
function EQFile = EQ_create_printFile (type,ID,pos,slip)

% EQ_create_printFile.m
% EQ Function that creates the .eq file name
% Nathanael Wong Zhixin, Feng Lujia
%
% This function is created for the purpose of determining the file name
% based on event inputs
%
% INPUT:
% -- type : model input type information
% -- ID : earthquake ID information
% -- pos : event location/depth information
% -- slip : event displacement information
%
% OUTPUT:
% -- EQFile : .eq file name
%
% FORMAT OF CALL: EQ_create_printFile (type,ID,pos,slip)
%
% OVERVIEW:
% 1) This function determines the filename of the .eq file and exports it
% to the parent function
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong



slab = EQtype(3); reg = EQtype(5);
date = EQID.ID(1); Mw = EQID.ID(2); depth = floor(EQpos.z(1)/1000);
name = EQ_create_printregname (reg); mu = EQslip.MME(2);
slab = type(3); reg = type(5);
date = ID.ID(1); Mw = ID.ID(2); depth = floor(pos.z(1)/1000);
name = EQ_create_printregname (reg); mu = slip.MME(2);

if any(slab == [1 1.1])
EQFile = [ 'EQ' num2str(date) '_' ...
Expand Down
27 changes: 23 additions & 4 deletions EQ_create_printHead.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
function EQ_create_printHead (fEQ,EQID)
function EQ_create_printHead (fEQ,ID)

% EQ_create_printHead.m
% EQ Function that prints the header information in .eq files
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the header information found at the top of .eq files
% to give the reader more information.
%
% INPUT:
% -- fEQ : .eq file ID
% -- ID : earthquake ID information
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printHead (fEQ,ID)
%
% OVERVIEW:
% 1) This function prints the header in the .eq files
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong


fprintf (fEQ, '# Earthquake DataFile for EQID: %s\n', EQID.name);
fprintf (fEQ, ' EQID %s\n\n', EQID.name);
fprintf (fEQ, '# Earthquake DataFile for EQID: %s\n', ID.name);
fprintf (fEQ, ' EQID %s\n\n', ID.name);
fprintf (fEQ, '# This DataFile compiles all data for the EQ event, to be extracted\n');
fprintf (fEQ, '# by EQ_ series functions. NaN is indicative that there is no need\n');
fprintf (fEQ, '# to extract these particular datapoints because they will be replaced\n');
Expand Down
21 changes: 20 additions & 1 deletion EQ_create_printInv0.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
function EQ_create_printInv0 (fEQ,O)


% EQ_create_printInv0.m
% EQ Function that prints the inversion information in .eq files
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the inversion information found at the top of .eq
% files to give the reader more information.
%
% INPUT:
% -- fEQ : .eq file ID
% -- O : inversion information for original setting
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printInv0 (fEQ,O)
%
% OVERVIEW:
% 1) This function prints the inversion in the .eq files
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

fprintf (fEQ, '# Inv0 rake0 rs0');
fprintf (fEQ, ' ');
Expand Down
21 changes: 20 additions & 1 deletion EQ_create_printInvN.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
function EQ_create_printInvN (fEQ,N)


% EQ_create_printInvN.m
% EQ Function that prints the inversion information in .eq files
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the inversion information found at the top of .eq
% files to give the reader more information.
%
% INPUT:
% -- fEQ : .eq file ID
% -- N : inversion information for number of patches
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printInvN (fEQ,N)
%
% OVERVIEW:
% 1) This function prints the inversion in the .eq files
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

fprintf (fEQ, '# InvN Nd Ns\n');

Expand Down
21 changes: 20 additions & 1 deletion EQ_create_printInvX.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
function EQ_create_printInvX (fEQ,X)


% EQ_create_printInvX.m
% EQ Function that prints the inversion information in .eq files
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the inversion information found at the top of .eq
% files to give the reader more information.
%
% INPUT:
% -- fEQ : .eq file ID
% -- X : inversion information for sweep settings
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printInvX (fEQ,X)
%
% OVERVIEW:
% 1) This function prints the inversion in the .eq files
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

fprintf (fEQ, '# InvX rakeX rsX');
fprintf (fEQ, ' ');
Expand Down
26 changes: 22 additions & 4 deletions EQ_create_printSlip.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
function EQ_create_printSlip (fEQ,EQslip)

function EQ_create_printSlip (fEQ,slip)

% EQ_create_printSlip.m
% EQ Function that prints the Fault Slip information in .eq files
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the fault slip information into the .eq file.
%
% INPUT:
% -- fEQ : .eq file ID
% -- slip : event slip information
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printSlip (fEQ,slip)
%
% OVERVIEW:
% 1) This function prints the slip information to the .eq files
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

fprintf (fEQ, '# Slip Rake Rig');
fprintf (fEQ, ' ');
Expand All @@ -10,8 +28,8 @@ function EQ_create_printSlip (fEQ,EQslip)
fprintf (fEQ, ' ');
fprintf (fEQ, '(m) (m) (m) (m)\n');

fprintf (fEQ, ' Slip %-5.1f %-2d', EQslip.MME);
fprintf (fEQ, ' Slip %-5.1f %-2d', slip.MME);
fprintf (fEQ, ' ');
fprintf (fEQ, '%-7.4f %-7.4f %-7.4f %-7.4f\n\n', EQslip.disp);
fprintf (fEQ, '%-7.4f %-7.4f %-7.4f %-7.4f\n\n', slip.disp);

end
24 changes: 21 additions & 3 deletions EQ_create_printType.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
function EQ_create_printType (fEQ,EQtype)

function EQ_create_printType (fEQ,type)

% EQ_create_printType.m
% EQ function that prints the model type info to string for filename
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the model type information into the .eq file.
%
% INPUT:
% -- fEQ : .eq file ID
% -- tyoe : GTdef model type information
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printType (fEQ,GTdef model type)
%
% OVERVIEW:
% 1) This function prints the GTdef model type into the .eq file
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

fprintf (fEQ, '# Type flt pnt slab evt reg\n');
fprintf (fEQ, ' Type %d %d %3.1f %d %d\n\n', EQtype);
fprintf (fEQ, ' Type %d %d %3.1f %d %d\n\n', type);

end
28 changes: 24 additions & 4 deletions EQ_create_printXYZ.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
function EQ_create_printXYZ (fEQ,EQpos)

function EQ_create_printXYZ (fEQ,pos)

% EQ_create_printXYZ.m
% EQ function that prints the event position to string for filename
% Nathanael Wong Zhixin, Feng Lujia
%
% This function prints the event position information into the .eq file.
%
% INPUT:
% -- fEQ : .eq file ID
% -- pos : structure containing event position information
% - .xy for (lon,lat) positioning
% - .z for (burial,locking) depth
%
% OUTPUT: N/A
%
% FORMAT OF CALL: EQ_create_printXYZ (fEQ,position information)
%
% OVERVIEW:
% 1) This function prints the GTdef model type into the .eq file
%
% VERSIONS:
% 1) -- Final version validated and commented on 20190715 by Nathanael Wong

fprintf (fEQ, '# XYZ lon1 lat1');
fprintf (fEQ, ' ');
Expand All @@ -14,8 +34,8 @@ function EQ_create_printXYZ (fEQ,EQpos)
fprintf (fEQ, ' ');
fprintf (fEQ, '(m) (m)\n');

fprintf (fEQ, ' XYZ %-08.3f %-07.3f %-08.3f %-07.3f', EQpos.xy);
fprintf (fEQ, ' XYZ %-08.3f %-07.3f %-08.3f %-07.3f', pos.xy);
fprintf (fEQ, ' ');
fprintf (fEQ, '%-06d %-06d\n\n', EQpos.z);
fprintf (fEQ, '%-06d %-06d\n\n', pos.z);

end
Loading

0 comments on commit f0fac7c

Please sign in to comment.