

# empty placeholder for the conditioned lines list to be rejoined into a string # iterates over each line and adds them to a list as long as they are not empty # holds the conditioned lines, namely the removal of empty lines # reads in the file by line rather than the default of by character Input_file = os.path.join(self.main_dir, 'Data', 'focal_mechanism_data.txt') # Conditions focal mechanism files downloaded from the Southern California Earthquake Data Center so that they can be usedĭef Condition_Focal_Mechanism_Data(self): The following demo script function removes the empty line and standardizes the delimiter to be tabs, then saves the conditioned data as a CSV file: In order to read the data into a data frame, it needs to be conditioned so that the aforementioned issues are resolved. The focal mechanism data as retrieved from the SCEDC does not have a uniform delimiter separating the columns and has an empty line between the column header and the column values. (Example of selecting and copying the focal mechanism data and column headers) Creating The Project Files Conditioning The Focal Mechanism Data Then save the text file to the Data folder and name it focal_mechanism_data. Select the data and column headers as shown below, and copy them into a text file. (Example of entering the focal mechanism parameters into the SCEDC focal mechanism catalog search)Īfter clicking the search button, the results are presented as a text page. This demo uses the following search parameters: Retrieve Focal Mechanism Dataįocal mechanism data will be acquired by downloading it from the SCEDC focal mechanism catalog. The Methods folder should contain the demo scripts. # Iterates through the list of directories and creates them if they don't already existĭata files used and created by the demo script will be located in the Data folder, and the focal mechanism map will save to the Results folder. Results_folder = os.path.join(main_dir, 'Results')ĭirectories = # path to the directory holding the map generated by the scripts Methods_folder = os.path.join(main_dir, 'Methods') # path to the directory holding the project Python scripts # path to the directory holding the project data filesĭata_folder = os.path.join(main_dir, 'Data') Main_dir = r'C:\Users\USER\Desktop\Focal_Mechanism_Demo' This script creates folders for the focal_mechanism_demo.py script if they don't already exist These folders can be created either by running the script provided below from anywhere after changing the main_dir file path to reflect your username or by manually creating a Focal_Mechanism_Demo folder and within it Data, Methods, and Results folders.
Python basemap 3d earthquake data for windows 10#
A diagram of the desired directory tree for Windows 10 is shown below: To follow this demo as written, project folders need to be created on the Desktop.
Python basemap 3d earthquake data code#
Please keep in mind that with the exception of the folder creation script, all code blocks shown in this demo are intended to be run as part of a complete script, which is included at the bottom of the page. In this demo, focal mechanism data will be retrieved from the Southern California Earthquake Data Center (SCEDC) and then plotted as focal mechanism “beach-balls” on a map with the geospatial Python package PyGMT. Rotated “beach-balls” with a white quarter in the center represent normal faulting, while “beach-balls” with a dark quarter in the center represent thrust faulting. When “beach-balls” present four equally sized quadrants in a “top-down” view like the one in the above diagram, strike-slip faulting is represented. A “beach-ball” has two possible orientations of fault movement, each along with one of the planes dividing the “beach-ball” into fourths, and determining the correct orientation requires additional information. Within a “beach-ball,” the dark quarters represent compressional forces and the white quarters represent tensional forces. (Image is sourced from the United States Geological Survey earthquake hazards webpage on focal mechanisms)


A focal mechanism is the orientation and type of slip of a fault, and it is represented as a “beach-ball” symbol. To better understand the faulting motions that create earthquakes, it can be useful to graphically display focal mechanisms. A comprehensive tutorial for plotting focal mechanism "beach-balls" using the PyGMT package for Python.
