Skip to content

Some suggestions#101

Open
mkamyab wants to merge 4 commits into
jonnymaserati:mainfrom
mkamyab:fix/some_suggestions
Open

Some suggestions#101
mkamyab wants to merge 4 commits into
jonnymaserati:mainfrom
mkamyab:fix/some_suggestions

Conversation

@mkamyab

@mkamyab mkamyab commented Feb 16, 2022

Copy link
Copy Markdown

While going over the code I edited some part of the code and thought it would be useful to share it with you.
I'm adding comments throughout the code to explain reasons for the suggestions.

Comment thread .gitignore
@@ -1 +1,1744 @@
{"header": {"name": null, "latitude": 60, "longitude": 0.0098, "altitude": 0.0, "survey_date": "2020-12-30", "b_total": 50000, "dip": 1.2566370614359172, "convergence": 0.0, "declination": -0.06981317007977318, "vertical_inc_limit": 1.7453292519943296e-06, "depth_unit": "meters", "surface_unit": "meters", "G": 9.80665, "azi_reference": "true"}, "survey": {"md": [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600, 630, 660, 690, 720, 750, 780, 810, 840, 870, 900, 930, 960, 990, 1020, 1050, 1080, 1110, 1140, 1170, 1200, 1230, 1260, 1290, 1320, 1350, 1380, 1410, 1440, 1470, 1500, 1530, 1560, 1590, 1620, 1650, 1680, 1710, 1740, 1770, 1800, 1830, 1860, 1890, 1920, 1950, 1980, 2010, 2040, 2070, 2100, 2130, 2160, 2190, 2220, 2250, 2280, 2310, 2340, 2370, 2400, 2430, 2460, 2490, 2520, 2550, 2580, 2610, 2640, 2670, 2700, 2730, 2760, 2790, 2820, 2850, 2880, 2910, 2940, 2970, 3000, 3030, 3060, 3090, 3120, 3150, 3180, 3210, 3240, 3270, 3300, 3330, 3360, 3390, 3420, 3450, 3480, 3510, 3540, 3570, 3600, 3630, 3660, 3690, 3720, 3750, 3780, 3810, 3840, 3870, 3900, 3930, 3960, 3990, 4020, 4050, 4080, 4110, 4140, 4170, 4200, 4230, 4260, 4290, 4320, 4350, 4380, 4410, 4440, 4470, 4500, 4530, 4560, 4590, 4620, 4650, 4680, 4710, 4740, 4770, 4800, 4830, 4860, 4890, 4920, 4950, 4980, 5010, 5040, 5070, 5100, 5130, 5160, 5190, 5220, 5250, 5280, 5310, 5340, 5370, 5400, 5430, 5460, 5490, 5520, 5550, 5580, 5610, 5640, 5670, 5700, 5730, 5760, 5790, 5820, 5850, 5880, 5910, 5940, 5970, 6000, 6030, 6060, 6090, 6120, 6150, 6180, 6210, 6240, 6270, 6300, 6330, 6360, 6390, 6420, 6450, 6480, 6510, 6540, 6570, 6600, 6630, 6660, 6690, 6720, 6750, 6780, 6810, 6840, 6870, 6900, 6930, 6960, 6990, 7020, 7050, 7080, 7110, 7140, 7170, 7200, 7230, 7260, 7290, 7320, 7350, 7380, 7410, 7440, 7470, 7500, 7530, 7560, 7590, 7620, 7650, 7680, 7710, 7740, 7770, 7800, 7830, 7860, 7890, 7920, 7950, 7980, 8000], "inc": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90], "azi": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75]}, "vd": {"md": [1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 5100, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000], "source": ["ABXY-TI1S", "ABXY-TI2S", "ABZ", "ASXY-TI1S", "ASXY-TI2S", "ASXY-TI3S", "ASZ", "MBXY-TI1S", "MBXY-TI2S", "MBZ", "MSXY-TI1S", "MSXY-TI2S", "MSXY-TI3S", "MSZ", "DECG", "DECR", "DBHG", "DBHR", "AMIL", "XYM1", "XYM2", "XYM3", "XYM4", "DRFR", "DSFS", "DSTG", "SAG", "Totals", "ABXY-TI1S", "ABXY-TI2S", "ABZ", "ASXY-TI1S", "ASXY-TI2S", "ASXY-TI3S", "ASZ", "MBXY-TI1S", "MBXY-TI2S", "MBZ", "MSXY-TI1S", "MSXY-TI2S", "MSXY-TI3S", "MSZ", "DECG", "DECR", "DBHG", "DBHR", "AMIL", "XYM1", "XYM2", "XYM3", "XYM4", "DRFR", "DSFS", "DSTG", "SAG", "Totals", "ABXY-TI1S", "ABXY-TI2S", "ABZ", "ASXY-TI1S", "ASXY-TI2S", "ASXY-TI3S", "ASZ", "MBXY-TI1S", "MBXY-TI2S", "MBZ", "MSXY-TI1S", "MSXY-TI2S", "MSXY-TI3S", "MSZ", "DECG", "DECR", "DBHG", "DBHR", "AMIL", "XYM1", "XYM2", "XYM3", "XYM4", "DRFR", "DSFS", "DSTG", "SAG", "Totals", "ABXY-TI1S", "ABXY-TI2S", "ABZ", "ASXY-TI1S", "ASXY-TI2S", "ASXY-TI3S", "ASZ", "MBXY-TI1S", "MBXY-TI2S", "MBZ", "MSXY-TI1S", "MSXY-TI2S", "MSXY-TI3S", "MSZ", "DECG", "DECR", "DBHG", "DBHR", "AMIL", "XYM1", "XYM2", "XYM3", "XYM4", "DRFR", "DSFS", "DSTG", "SAG", "Totals"], "nn": [0.2336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.2775, 0, 0, 0, 0, 0, 4.5111, 0.8808, 0.0353, 0.1213, 0.0462, 0.0231, 0.0016, 0.0924, 1.9152, 0.1287, 1.2861, 0.4237, 0.1128, 0.1229, 0.8474, 6.8003, 0.022, 5.4949, 0.0831, 12.7039, 0.0212, 0.5247, 11.2525, 0.0022, 0.0062, 0.0039, 0.0071, 0.0847, 43.0442, 6.5736, 0.0316, 10.008, 2.0593, 1.0296, 0.0012, 4.1186, 48.5001, 6.3917, 116.6281, 22.6961, 6.2112, 5.3009, 45.3922, 337.6662, 0.2139, 272.8462, 0.8063, 1152.0003, 0.5363, 26.0545, 34.6306, 0.1402, 0.0064, 0.1926, 0.7056, 2.1453, 2102.8867, 7.0321, 0.2114, 43.4534, 2.2686, 1.1343, 0.1262, 4.5371, 52.8759, 24.3873, 535.6945, 31.0317, 4.9596, 13.3796, 62.0635, 1288.3506, 0.4585, 1041.0326, 1.7284, 5291.3497, 0.5847, 99.4098, 36.1537, 0.1573, 0.0084, 0.7348, 2.3143, 2.3388, 8547.7769], "ee": [0, 0.2336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.2775, 0, 0, 0, 0, 4.5111, 0.0201, 0.2914, 0.0018, 0.0012, 0.0006, 0.0001, 0.0023, 0.1375, 0.0092, 0.0923, 0.0304, 0.0081, 0.0088, 0.0608, 0.4882, 0.0016, 0.3945, 0.006, 0.9121, 0.295, 0.0377, 0.0022, 10.1818, 0.0868, 0.054, 0.0994, 1.1799, 14.4041, 0.0005, 0.2885, 0.0266, 0.003, 0.0015, 0.0001, 0.0061, 3.4822, 0.4589, 8.3735, 1.6295, 0.4459, 0.3806, 3.259, 24.2433, 0.0154, 19.5895, 0.0579, 82.7099, 7.4699, 1.8706, 0.1402, 21.0459, 0.0886, 2.6823, 9.828, 29.8795, 217.9769, 0.0001, 0.1341, 1.1056, 0.0043, 0.0021, 0.0091, 0.0085, 3.7963, 1.7509, 38.4611, 2.228, 0.3561, 0.9606, 4.456, 92.4994, 0.0329, 74.7428, 0.1241, 379.9018, 8.1438, 7.1373, 0.1573, 21.5203, 0.1175, 10.2341, 32.2338, 32.5753, 712.6932], "vv": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1225, 0.4516, 0.1296, 0, 0.7037, 0.0173, 0, 0.0116, 0.0043, 0.0022, 0, 0.0087, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2123, 0, 0.0212, 0.295, 0.0337, 1.1854, 0.8121, 0.8492, 3.453, 0.4373, 0, 1.0515, 0.2149, 0.1074, 0, 0.4297, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19.2524, 0, 0.5363, 7.4699, 0.0319, 3.7201, 6.6901, 77.0098, 116.9514, 0.4767, 0, 4.8297, 0.2373, 0.1187, 0, 0.4746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88.43, 0, 0.5847, 8.1438, 0.0042, 3.8878, 7.2192, 353.7202, 468.127], "ne": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1332, -0.1014, 0.0149, 0.0073, 0.0037, -0.0004, 0.0147, -0.5132, -0.0345, -0.3446, -0.1135, -0.0302, -0.0329, -0.2271, -1.8221, -0.0059, -1.4723, -0.0223, -3.404, 0.079, -0.1406, -0.1584, -0.1507, 0.0233, 0.0145, 0.0266, 0.3161, -7.9409, 0.0592, -0.0955, -0.5159, -0.079, -0.0395, -0.0003, -0.1581, -12.9956, -1.7127, -31.2504, -6.0814, -1.6643, -1.4204, -12.1628, -90.4774, -0.0573, -73.1089, -0.216, -308.6776, 2.0015, -6.9813, -2.2037, -1.7179, 0.0237, 0.7187, 2.6334, 8.0062, -538.1731, 0.028, 0.1684, -6.9314, -0.0985, -0.0492, -0.0338, -0.1969, -14.1681, -6.5346, -143.5389, -8.3149, -1.3289, -3.585, -16.6299, -345.2125, -0.1228, -278.9439, -0.4631, -1417.8129, 2.1821, -26.6368, -2.3846, -1.8397, 0.0315, 2.7422, 8.637, 8.7285, -2252.3087], "nv": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.1233, 0, -0.0375, -0.0141, -0.0071, 0, -0.0283, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0671, 0, -0.4882, 0.0256, 0.0136, 0.0678, 0.0761, -0.2682, -0.8506, -1.6954, 0, -3.244, -0.6652, -0.3326, 0, -1.3303, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3.2133, 0, -4.3096, 1.0235, 0.0133, 0.8464, 2.1727, -12.8532, -23.5877, -1.8309, 0, -14.4869, -0.7337, -0.3669, 0, -1.4675, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7.1906, 0, -4.5977, 1.1317, -0.0006, 1.6902, 4.0874, -28.7625, -52.528], "ev": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0186, 0, -0.0046, -0.0022, -0.0011, 0, -0.0045, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.2503, 0, 0.0069, -1.733, 0.0507, 0.253, 0.2841, -1.001, -2.4206, -0.0153, 0, 0.1672, 0.0255, 0.0128, 0, 0.0511, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -11.9922, 0, 0.2742, -12.5383, 0.0497, 3.1589, 8.1087, -47.9689, -60.6667, -0.0073, 0, 2.3108, 0.0318, 0.0159, 0, 0.0637, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -26.8358, 0, 0.3032, -13.2385, -0.0023, 6.3078, 15.2545, -107.3431, -123.139]}} No newline at end of file
{

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is easier to read through if it is formatted properly in JSON form.

Comment on lines +1 to -9
import os

import numpy as np
from numpy import sin, cos, tan, pi, sqrt
from numpy.core.defchararray import index
import yaml
import os

from collections import OrderedDict
# import imp
from numpy import sin, cos, tan, pi, sqrt

# import welleng.error

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Sorted the imports
  • Removed from numpy.core.defchararray import index since it wasn't used in the file.

Comment thread welleng/survey.py
'dip': 70.,
'declination': 0.,
},
mag_defaults=None,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization of function arguments to mutable objects is not recommended in python. Check "Using mutable objects as default argument values in python" of this page.

Comment thread welleng/survey.py
def _get_radius(self, radius=None):
if radius is None:
self.radius = np.full_like(self.md.astype(float), 0.3048)

@mkamyab mkamyab Feb 16, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is advisable to put an extra line after the if clause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants