How to start - VicenteYanez/GFA GitHub Wiki
Configuring GFA software
GFA just need to be installed via pip3 (pip3 install gfa). It requires is numpy, matplotlib, scipy and cartopy modules. Also, you need configure the time series data. For doing this you have to copy your time series files inside the GFA/data directory. The time series files should have the next structure:
- GFA/data/TimeSeries/txtfile/*.txt <----- all the txt files with the time series for each station, and the name of the file should be the name of the station.
- GFA/data/TimeSeries/station_list.txt <----- a txt file with the name, longitude and latitude for each station.
The time series data inside the txtfile/ directory should have this format:
Each column has to be separated for at least one space. On the other hand, the station_list.txt file, should have this format:
Each column has to be separated for at least one space and the first row is omitted.
Although I understand there are many format types for a time series, for now I only have one function that loads the data. So if you want to keep your own format, you have to modify the loadGPS.formatCSN() function (or create another function for load the data).
Also, in GFA/data directory you can put a file named eq_file.txt. This file have the seismic event you want to consider for the calculation of the trajectory model. The format for this file is the following.
Sadly, for the first version of GFA only the latitude rate is considered. In the future a better way for including the seismic catalog in the calculation of the trajectory model will be implemented.
Calculate a general solution for the model
Although is not strictly necessary, it is very helpful to generate a first general solution for the trajectory model for all the stations. This is get by executing in bash $gfa buildmodelall script. This solution use predefine parameters (and the events in eq_file.txt) for all the stations. The results are saved in example_files/general_solution/ directory.
Select
After the time series data have been correctly formatted, the next thing to do is to use the $gfa select script to extract the time series (and the model data if the general solution was created) giving a specific area and time interval. For example writing in the command line $gfa select --alias test --lonmin -75 --lonmax -65 --latmin -48 --latmax -35 --tmin 2007 --tmax 2012 creates the directory GFA/example_files/test with the gnss data for the area between the latitudes 48 to 35ºS and longitudes -75 to -65ºW, and the years 2007 to 2012. The first parameter 'test' is only an identifier and you can use whatever other word or number you desire. For the sake of this tutorial, we are going to continue using the 'test' identifier.
Ploting, rebuilding and calculating a vector
The next thing you surely want to do, is to visualize the time series for your area and time. You can do this with the ts_plot script. With the command $gfa plot --alias test --station CLLA. This commands plot and save the time series (and the model if there is any) for the station CLLA in your test directory. If you add --model -m the model data is also plotted with a green line (if there is any), and with --vector -v a vector is plotted (if you have already computed it).
Probably, you will see that the model of the general solution is not perfect. So, you probably want to calculate a new trajectory model with your own parameters. GFA provides two ways for doing this. First, the gfa build is a simple script that takes a list of parameters for a station and builds a new model for it. Then you call the script with $gfa build --alias test --station (see gfa build --help for a complete list of parameters), and the new model is computed and saved inside the test directory.
The second way is the ui_buildmodel script. This script is a command line user interface for computing, visualizing and recomputing the trajectory model for a single station. You can run the script until you have a model you are satisfied with, the data is automatically saved in the select folder. You can run it with the command $gfa uimodel --alias test --station CLLA (or whatever other station in your test directory).
Next, we will see the different ways to compute a vector from the trajectory model.
Tangent vector
With $gfa vector --alias test --station CLLA --type tangent --period 2009 you can calculate a vector from the tangent of the model when t=2009. This will save the vector in the file vectors.txt inside your test directory. For visualizing the vector in the time series plot, use $gfa plot --alias test --station CLLA --model -m --vector -v. You can see it in the next figure, drawn like a red line.
Fit vector
With $gfa vector --alias test --station CLLA --type fit --period 2010,2011 you can calculate a vector from adjusting with minimal quadratic routines (scipy.optimize.curve_fit) the model to a straight line for a specific time range (in this case between the year 2010 and 2011). This will save the vector in the file vectors.txt inside your test directory. Also, as you can see in the next figure, you can have more than one vector for a single station.
Trend Vector
The last way uses the trend component of the trajectory model but there isn't a straight forward script to extract it yet.
What is next? The Field Analysis
After you finish to computing all the vectors for your stations, you can use the vectors.txt file to calculate the velocity field and the vorticity or stretching tensor. Sadly, GFA doesn't have a user interface for doing this yet However in the field analysis directory you will find helper functions and an example script. This example calculates the vorticity field in the southern Andes from a vector file.
Finally, even though this tutorial embraces all the user-ready scripts, the GFA software have many python functions and classes you can use for your own scripts or user-interface. I invite you to explore them.