mraggi / sismos

Para ayudar a Luis Antonio con lo de hacer inversión en sismos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interplate slip rate variation between closely spaced earthquakes in southern Mexico: The 2012 Ometepec and 2018 Pinotepa Nacional thrust events

DOI

Distance Matrix to points

In this repository we provide code to attempt to solve the following problem: Given an approximate distance (symmetric) matrix, produce points in 2d-space for which the pairwise distance matrix matches the given one. This is useful in earthquake analysis, apparently. For a more in-depth explanation, please see this notebook.

Install

To install, you first need to install pytorch and fastprogress. It is recommended to use a separate conda environment.

For example, with anaconda:

conda activate [my_env_name]
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
conda install fastprogress -c fastai

Make sure cudatoolkit version matches your own cuda instalation.

Alternatively, install with pip:

pip install --user torch torchvision
pip install --user fastprogress 

Usage

You need a matrix in a space separated file. For example, say your matrix is in a file called matrix.txt. Then just run in a terminal:

python sismos.py matrix.txt

to use the default settings.

Help

The full set of options are described below. See the bottom of the README for an example.

usage: sismos.py [-h] [-t TIME] [-e ERROR] [-n NUM_RESTARTS] [-p POP_SIZE]
                 [-s SHUFFLES] [-d]
                 matrix

positional arguments:
  matrix                file with (symmetric) distance matrix

optional arguments:
  -h, --help            show this help message and exit
  -t TIME, --time TIME  Number of seconds to spend finding a good solution
                        (per restart) (default: 10)
  -e ERROR, --error ERROR
                        either use L1, L2, or smoothL1 (default: L2)
  -n NUM_RESTARTS, --num_restarts NUM_RESTARTS
                        Number of times that we try to restart (default: 5)
  -p POP_SIZE, --pop_size POP_SIZE
                        Population size for diff evo (default: 60)
  -s SHUFFLES, --shuffles SHUFFLES
                        Number of times populations mix. (default: 1)
  -d, --disable_cuda    If true, disable CUDA (even when available). If false,
                        use CUDA only if available. Ignored if you don't have
                        CUDA. (default: False)

Example usage

A run could look like this:

python sismos.py matrix.txt --time 60 --error L1 --num_restarts 8 --pop_size 100 --shuffles 2 --disable_cuda

The above command runs for 1 minute, uses L1 error instead of L2, and considers 8 populations, each of size 100. Furthermore, after ~20 and ~40 seconds, we mix the 8 populations (for a total of 2 shuffles). CUDA is disabled.

This project was supported by PAPIIT IN1169919.

About

Para ayudar a Luis Antonio con lo de hacer inversión en sismos

License:MIT License


Languages

Language:Python 73.9%Language:Jupyter Notebook 23.3%Language:Sage 2.9%