Skip to content

Commit

Permalink
Trying to clean up this directory completely
Browse files Browse the repository at this point in the history
  • Loading branch information
kasra-hosseini committed Apr 23, 2014
1 parent dd7a2f6 commit 2b50b57
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
DATA
ARCHIVE
GALLERY
39 changes: 18 additions & 21 deletions Pyfiles/create_dataset1_wri.py → pyfiles/create_dataset1_wri.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
'''
Goal: Create dataset1_wri for testing purposes
'''
"""
Python script to create dataset1_wri for testing purposes
"""

import numpy as np
from obspy.core.util import locations2degrees
import os
import sys
import utils
import utils as utl

#-----------------INPUT--------------------
phase = 'P'
filename = 'dataset1_wri_example'
#------------------------------------------

if os.path.exists(os.path.join('.', filename)):
sys.exit('ERROR: %s exists' %(filename))
sys.exit('ERROR: %s exists' % filename)

# Example 1:
#source = [[90., 0., 100.]]
#receiver = [[30., 0., 0.]]
source = [[90., 0., 100.]]
receiver = [[30., 0., 0.]]

# Example tomo:
# used for P crustal correction map
Expand Down Expand Up @@ -74,11 +72,11 @@
# source.append([90.0, 10.0, 0.0])

# Example 4
source = []
receiver = []
for i in range(32, 90, 1):
receiver.append([0.0, i, 0.0])
source.append([0.0, 0.0, 0.0])
#source = []
#receiver = []
#for i in range(32, 90, 1):
# receiver.append([0.0, i, 0.0])
# source.append([0.0, 0.0, 0.0])
#for i in range(100, 180, 1):
# receiver.append([0.0, i, 0.0])
# source.append([0.0, 0.0, 0.0])
Expand All @@ -95,26 +93,25 @@


# Creating the header (wave definition + filters)
comp_header = utils.dataset_header(phase, filename)
comp_header = utl.dataset_header(phase, filename)
comp_header = comp_header.split('\n')
comp_file = []
for i in range(len(comp_header)-1, -1, -1):
if not comp_header[i].isspace() and \
not comp_header[i] == '':
if not comp_header[i].isspace() and not comp_header[i] == '':
comp_file.append(comp_header[i])
comp_file.reverse()

# Creating the required source-receiver pairs
srcrcv = utils.source_receiver(source, receiver)
srcrcv = utl.source_receiver(source, receiver)
for i in range(len(srcrcv)):
comp_file.append(srcrcv[i])

fio = open(os.path.join('.', filename), 'w')
fio = open(os.path.join(os.path.curdir, filename), 'w')
for i in range(len(comp_file)):
fio.writelines(comp_file[i] + '\n')
fio.close()

fio = open(os.path.join('.', 'in.'+filename), 'w')
fio = open(os.path.join(os.path.curdir, 'in.%s' % filename), 'w')
fio.writelines('IASP91\n')
fio.writelines('1 20\n')
fio.writelines(filename + '\n')
Expand All @@ -123,5 +120,5 @@
elif phase.lower() == 'p':
fio.writelines('Pdef_P')
else:
sys.exit('ERROR: unrecognized phase: %s' %(phase))
sys.exit('ERROR: unrecognized phase: %s' % phase)
fio.close()
5 changes: 3 additions & 2 deletions Pyfiles/plot_ellip_perc.py → pyfiles/plot_ellip_perc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'''
"""
Plot the difference between ellipticity corrections (two methods)
'''
"""

import matplotlib.pyplot as plt
import os
import sys
Expand Down
17 changes: 8 additions & 9 deletions Pyfiles/plot_ray_tracer.py → pyfiles/plot_ray_tracer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'''
"""
Plot the ray which has been traced!
Not completely implemented!
input: output of raydata program
'''
"""

import matplotlib.pyplot as plt
import numpy as np
import os
Expand All @@ -25,7 +26,7 @@
# r: radius, delta: epicentral distance (radians)
r = []
delta = []
for i in range(line_to_start,line_to_start+number_lines_2_read):
for i in range(line_to_start, line_to_start+number_lines_2_read):
fi_tmp = fi[i].split()
if len(fi_tmp) == 7:
r.append(float(fi_tmp[0]))
Expand All @@ -36,17 +37,15 @@
ax.plot(delta, r, color='r', linewidth=3)

# DIRTY! plot ICB and CMB
ax.plot(np.linspace(0,360,10000), np.ones(10000)*ICB, lw=1.0, color='k')
ax.plot(np.linspace(0,360,10000), np.ones(10000)*CMB, lw=1.0, color='k')
ax.plot(np.linspace(0, 360, 10000), np.ones(10000)*ICB, lw=1.0, color='k')
ax.plot(np.linspace(0, 360, 10000), np.ones(10000)*CMB, lw=1.0, color='k')

# change the theta direction to clockwise!
ax.set_theta_direction(-1)
ax.set_theta_zero_location('N')

ax.set_thetagrids([0, 45, 90, 135, 180, 225, 270, 315],
size='x-large', weight='bold')
ax.set_rgrids([ICB, CMB], labels=['ICB', 'CMB'],
size='x-large', weight='bold')
ax.set_thetagrids([0, 45, 90, 135, 180, 225, 270, 315], size='x-large', weight='bold')
ax.set_rgrids([ICB, CMB], labels=['ICB', 'CMB'], size='x-large', weight='bold')
ax.set_rmax(Rad)

plt.show()
File renamed without changes.
22 changes: 14 additions & 8 deletions Pyfiles/utils.py → pyfiles/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""
Utility functions for create_dataset1_wri
"""
import sys


################ dataset_header #####################


def dataset_header(phase, filename_io):
'''
"""
Includes correct header for dataset file!
'''
"""

pdiff_header = filename_io + \
'''
Expand Down Expand Up @@ -401,21 +406,22 @@ def dataset_header(phase, filename_io):
complete_header = pdiff_header + filters
return complete_header
else:
print 'Invalid phase! %s' %(phase)
print 'Invalid phase! %s' % phase
sys.exit(1)

################### source_receiver ##########################


def source_receiver(source, receiver):
'''
"""
Create required lines for source and receiver
'''
"""

srv = []
for i in range(len(source)):
srv.append('20%s %s %s 1 S%s N%s BHZ %s %s %s %s %s %s 8 0 0'
%(i, i, i, i, i,
source[i][0], source[i][1], source[i][2],
receiver[i][0], receiver[i][1], receiver[i][2]))
% (i, i, i, i, i, source[i][0], source[i][1], source[i][2], receiver[i][0], receiver[i][1],
receiver[i][2]))
srv.append('1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0')
srv.append(' 100 0.9 0.9 1 65.1')
srv.append(' 100 0.9 0.9 2 46.2')
Expand Down

0 comments on commit 2b50b57

Please sign in to comment.