Skip to content

Commit cd5d323

Browse files
rzinkerzinke
andauthored
Ensure consistency for comment style and indentation (#75)
Co-authored-by: rzinke <robert.zinke@jpl.nasa.gov>
1 parent e62b740 commit cd5d323

File tree

4 files changed

+187
-174
lines changed

4 files changed

+187
-174
lines changed

methods/coseismic/Coseismic_Requirement_Validation.ipynb

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,11 @@
600600
"command = 'timeseries2velocity.py ' + timeseries_filename + function_str\n",
601601
"process = subprocess.run(command, shell=True)\n",
602602
"\n",
603-
"# load velocity file\n",
603+
"# Load velocity file\n",
604604
"insar_velocities,_ = readfile.read(vel_file, datasetName = 'velocity') # read velocity file\n",
605605
"insar_velocities = insar_velocities * 1000. # convert InSAR velocities from m/yr to mm/yr\n",
606606
"\n",
607-
"# set masked pixels to NaN\n",
607+
"# Set masked pixels to NaN\n",
608608
"msk,_ = readfile.read(msk_file)\n",
609609
"insar_velocities[msk == 0] = np.nan\n",
610610
"insar_velocities[insar_velocities == 0] = np.nan"
@@ -739,13 +739,15 @@
739739
"bbox = sitedata['sites'][site]['analysis_region'].replace(\"'\",\"\").split()\n",
740740
"lat0 = (float(bbox[0]) + float(bbox[1]))/2\n",
741741
"lon0 = (float(bbox[2]) + float(bbox[3]))/2\n",
742+
"\n",
742743
"# Identify geometry file x/y location associated with center lat/lon\n",
743744
"geom_obj = mintpy_dir + '/inputs/geometryGeo.h5'\n",
744745
"atr = readfile.read_attribute(geom_obj)\n",
745746
"coord = ut.coordinate(atr, lookup_file=geom_obj)\n",
746747
"y, x = coord.geo2radar(lat0, lon0)[0:2]\n",
747748
"y = max(0, y); y = min(int(atr['LENGTH'])-1, y)\n",
748749
"x = max(0, x); x = min(int(atr['WIDTH'])-1, x)\n",
750+
"\n",
749751
"# Write out inclination/azimuth at specified x/y location\n",
750752
"kwargs = dict(box=(x,y,x+1,y+1))\n",
751753
"inc_angle = readfile.read(geom_obj, datasetName='incidenceAngle', **kwargs)[0][0,0]\n",
@@ -1329,7 +1331,7 @@
13291331
},
13301332
"outputs": [],
13311333
"source": [
1332-
"# use the non-earthquake displacement as the insar_displacment for statistics and convert to mm\n",
1334+
"# Use the non-earthquake displacement as the insar_displacment for statistics and convert to mm\n",
13331335
"noEQdataset = 'step' + sitedata['sites'][site]['noEarthquakeDate']\n",
13341336
"noEQstep, insar_metadata = readfile.read(vel_file, datasetName = noEQdataset) #read coseismic step \n",
13351337
"(S,N,W,E) = ut.four_corners(insar_metadata)\n",
@@ -1340,12 +1342,12 @@
13401342
"ifgs_date = np.array([noEQdate]) # only one non-earthquake date for now\n",
13411343
"n_ifgs = insar_displacement.shape[0]\n",
13421344
"\n",
1343-
"# mask out no-data areas\n",
1345+
"# Mask out no-data areas\n",
13441346
"msk, _ = readfile.read(msk_file)\n",
13451347
"insar_displacement[msk == 0] = np.nan\n",
13461348
"insar_displacement[insar_displacement == 0] = np.nan\n",
13471349
"\n",
1348-
"# display map of data after masking\n",
1350+
"# Display map of data after masking\n",
13491351
"cmap = plt.get_cmap('RdBu')\n",
13501352
"fig, ax = plt.subplots(figsize=[18, 5.5])\n",
13511353
"img1 = ax.imshow(insar_displacement, cmap=cmap, interpolation='nearest', extent=(W, E, S, N))\n",
@@ -1638,12 +1640,12 @@
16381640
},
16391641
"outputs": [],
16401642
"source": [
1641-
"# grab the time-series file used for time function estimation given the template setup\n",
1643+
"# Grab the time-series file used for time function estimation given the template setup\n",
16421644
"template = readfile.read_template(os.path.join(mintpy_dir, 'smallbaselineApp.cfg'))\n",
16431645
"template = ut.check_template_auto_value(template)\n",
16441646
"insar_ts_file = TimeSeriesAnalysis.get_timeseries_filename(template, mintpy_dir)['velocity']['input']\n",
16451647
"\n",
1646-
"# read the time-series file\n",
1648+
"# Read the time-series file\n",
16471649
"insar_ts, atr = readfile.read(insar_ts_file, datasetName='timeseries')\n",
16481650
"mask = readfile.read(os.path.join(mintpy_dir, 'maskTempCoh.h5'))[0]\n",
16491651
"print(f'reading timeseries from file: {insar_ts_file}')\n",
@@ -1654,7 +1656,7 @@
16541656
"date0, date1 = date_list[0], date_list[-1]\n",
16551657
"insar_dates = ptime.date_list2vector(date_list)[0]\n",
16561658
"\n",
1657-
"# spatial reference\n",
1659+
"# Spatial reference\n",
16581660
"coord = ut.coordinate(atr)\n",
16591661
"ref_site = sitedata['sites'][site]['gps_ref_site_name']\n",
16601662
"ref_gnss_obj = gnss_stns[ref_site]\n",
@@ -1670,8 +1672,8 @@
16701672
"for i, site_name in enumerate(site_names):\n",
16711673
" prog_bar.update(i+1, suffix=f'{site_name} {i+1}/{num_site}')\n",
16721674
"\n",
1673-
" ## read data\n",
1674-
" # recall gnss station displacements with outliers removed\n",
1675+
" ## Read data\n",
1676+
" # Recall gnss station displacements with outliers removed\n",
16751677
" gnss_obj = gnss_stns[site_name]\n",
16761678
" gnss_lalo = (gnss_obj.site_lat, gnss_obj.site_lon)\n",
16771679
"\n",
@@ -1683,10 +1685,10 @@
16831685
" idx2 = np.where(ref_gnss_obj.dates == date_i)[0][0]\n",
16841686
" gnss_dis[i] = gnss_obj.dis_los[idx1] - ref_gnss_obj.dis_los[idx2]\n",
16851687
" \n",
1686-
" # shift GNSS to zero-mean in time [for plotting purpose]\n",
1688+
" # Shift GNSS to zero-mean in time [for plotting purpose]\n",
16871689
" gnss_dis -= np.nanmedian(gnss_dis)\n",
16881690
"\n",
1689-
" # read InSAR\n",
1691+
" # Read InSAR\n",
16901692
" y, x = coord.geo2radar(gnss_lalo[0], gnss_lalo[1])[:2]\n",
16911693
" insar_dis = insar_ts[:, y, x] - ref_insar_dis\n",
16921694
" # apply a constant shift in time to fit InSAR to GNSS\n",
@@ -1696,7 +1698,7 @@
16961698
" gnss_flag = [x in comm_dates for x in gnss_dates]\n",
16971699
" insar_dis -= np.nanmedian(insar_dis[insar_flag] - gnss_dis[gnss_flag])\n",
16981700
"\n",
1699-
" ## plot figure\n",
1701+
" ## Plot figure\n",
17001702
" if gnss_dis.size > 0 and np.any(~np.isnan(insar_dis)):\n",
17011703
" fig, ax = plt.subplots(figsize=(10, 3))\n",
17021704
" ax.axhline(color='grey',linestyle='dashed', linewidth=2)\n",
@@ -1706,6 +1708,7 @@
17061708
" ax.set_title(f\"Station Name: {site_name}\") \n",
17071709
" ax.set_ylabel('LOS displacement [mm]')\n",
17081710
" ax.legend()\n",
1711+
"\n",
17091712
"prog_bar.close()\n",
17101713
"plt.show()"
17111714
]

methods/secular/Secular_Requirement_Validation.ipynb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,11 @@
627627
"command = 'timeseries2velocity.py ' + timeseries_filename + function_str\n",
628628
"process = subprocess.run(command, shell=True)\n",
629629
"\n",
630-
"# load velocity file\n",
630+
"# Load velocity file\n",
631631
"insar_velocities,_ = readfile.read(vel_file, datasetName = 'velocity') # read velocity file\n",
632632
"insar_velocities = insar_velocities * 1000. # convert InSAR velocities from m/yr to mm/yr\n",
633633
"\n",
634-
"# set masked pixels to NaN\n",
634+
"# Set masked pixels to NaN\n",
635635
"msk,_ = readfile.read(msk_file)\n",
636636
"insar_velocities[msk == 0] = np.nan\n",
637637
"insar_velocities[insar_velocities == 0] = np.nan"
@@ -943,14 +943,14 @@
943943
},
944944
"outputs": [],
945945
"source": [
946-
"# reference GNSS stations to GNSS reference site\n",
946+
"# Reference GNSS stations to GNSS reference site\n",
947947
"ref_site = sitedata['sites'][site]['gps_ref_site_name']\n",
948948
"if sitedata['sites'][site]['gps_ref_site_name'] == 'auto':\n",
949949
" ref_site = [*gnss_stns][0]\n",
950950
"\n",
951951
"print(\"Using GNSS reference station: \", ref_site)\n",
952952
"\n",
953-
"# re-reference GNSS sites\n",
953+
"# Re-reference GNSS sites\n",
954954
"if 'vel_mm_yr' in gnss_stns[ref_site].vel_dict:\n",
955955
" ref_vel = gnss_stns[ref_site].vel_dict['vel_mm_yr']\n",
956956
"\n",
@@ -963,12 +963,12 @@
963963
" # Remove non-referenced station data to avoid future confusion\n",
964964
" del gnss_stn.vel_dict['vel_mm_yr']\n",
965965
"\n",
966-
"# reference InSAR to GNSS reference site\n",
966+
"# Reference InSAR to GNSS reference site\n",
967967
"ref_site_lat, ref_site_lon = gnss_stns[ref_site].get_site_lat_lon()\n",
968968
"ref_y, ref_x = ut.coordinate(insar_metadata).geo2radar(ref_site_lat, ref_site_lon)[:2]\n",
969969
"insar_velocities = insar_velocities - insar_velocities[ref_y, ref_x]\n",
970970
"\n",
971-
"# plot GNSS stations on InSAR velocity field\n",
971+
"# Plot GNSS stations on InSAR velocity field\n",
972972
"vmin, vmax = -25, 25\n",
973973
"cmap = plt.get_cmap('RdBu_r')\n",
974974
"\n",
@@ -1028,27 +1028,27 @@
10281028
},
10291029
"outputs": [],
10301030
"source": [
1031-
"#Set Parameters\n",
1031+
"# Set Parameters\n",
10321032
"pixel_radius = 5 #number of InSAR pixels to average for comparison with GNSS\n",
10331033
"\n",
1034-
"#Loop over GNSS station locations\n",
1034+
"# Loop over GNSS station locations\n",
10351035
"for site_name in site_names:\n",
10361036
" gnss_stn = gnss_stns[site_name]\n",
10371037
" \n",
1038-
" # convert GNSS station lat/lon information to InSAR x/y grid\n",
1038+
" # Convert GNSS station lat/lon information to InSAR x/y grid\n",
10391039
" stn_lat, stn_lon = gnss_stn.get_site_lat_lon()\n",
10401040
" stn_y, stn_x = ut.coordinate(insar_metadata).geo2radar(stn_lat, stn_lon)[:2]\n",
10411041
" \n",
1042-
" # get velocities and residuals\n",
1042+
" # Get velocities and residuals\n",
10431043
" gnss_site_vel = gnss_stn.vel_dict['gnss_site_vel']\n",
1044-
" #Caution: If you expand the radius parameter farther than the bounding grid it will break. \n",
1045-
" #To fix, remove the station in section 4 when the site_names list is filtered\n",
1044+
" # Caution: If you expand the radius parameter farther than the bounding grid it will break. \n",
1045+
" # To fix, remove the station in section 4 when the site_names list is filtered\n",
10461046
" vel_px_rad = insar_velocities[stn_y-pixel_radius:stn_y+1+pixel_radius, \n",
10471047
" stn_x-pixel_radius:stn_x+1+pixel_radius]\n",
10481048
" insar_site_vel = np.median(vel_px_rad)\n",
10491049
" residual = gnss_site_vel - insar_site_vel\n",
10501050
"\n",
1051-
" # populate data structure\n",
1051+
" # Populate data structure\n",
10521052
" gnss_stn.vel_dict['insar_site_vel'] = insar_site_vel\n",
10531053
" gnss_stn.vel_dict['residual'] = residual\n",
10541054
"\n",
@@ -1076,7 +1076,7 @@
10761076
"stn_dist_list = []\n",
10771077
"n_gnss_sites = len(site_names)\n",
10781078
"\n",
1079-
"# loop over stations\n",
1079+
"# Loop over stations\n",
10801080
"for i in range(n_gnss_sites - 1):\n",
10811081
" stn1 = gnss_stns[site_names[i]]\n",
10821082
" for j in range(i + 1, n_gnss_sites):\n",
@@ -1195,17 +1195,17 @@
11951195
"metadata": {},
11961196
"outputs": [],
11971197
"source": [
1198-
"# use the assumed non-earthquake displacement as the insar_displacment for statistics and convert to mm\n",
1198+
"# Use the assumed non-earthquake displacement as the insar_displacment for statistics and convert to mm\n",
11991199
"insar_velocities,_ = readfile.read(vel_file, datasetName = 'velocity') #read velocity\n",
12001200
"velStart = sitedata['sites'][site]['download_start_date']\n",
12011201
"insar_velocities = insar_velocities * 1000. # convert velocities from m to mm\n",
12021202
"\n",
1203-
"# set masked pixels to NaN\n",
1203+
"# Set masked pixels to NaN\n",
12041204
"msk,_ = readfile.read(msk_file)\n",
12051205
"insar_velocities[msk == 0] = np.nan\n",
12061206
"insar_velocities[insar_velocities == 0] = np.nan\n",
12071207
"\n",
1208-
"# display map of velocity data after masking\n",
1208+
"# Display map of velocity data after masking\n",
12091209
"cmap = plt.get_cmap('RdBu_r')\n",
12101210
"fig, ax = plt.subplots(figsize=[18, 5.5])\n",
12111211
"img1 = ax.imshow(insar_velocities, cmap=cmap, vmin=-20, vmax=20, interpolation='nearest', extent=(W, E, S, N))\n",
@@ -1438,12 +1438,12 @@
14381438
},
14391439
"outputs": [],
14401440
"source": [
1441-
"# grab the time-series file used for time function estimation given the template setup\n",
1441+
"# Grab the time-series file used for time function estimation given the template setup\n",
14421442
"template = readfile.read_template(os.path.join(mintpy_dir, 'smallbaselineApp.cfg'))\n",
14431443
"template = ut.check_template_auto_value(template)\n",
14441444
"insar_ts_file = TimeSeriesAnalysis.get_timeseries_filename(template, mintpy_dir)['velocity']['input']\n",
14451445
"\n",
1446-
"# read the time-series file\n",
1446+
"# Read the time-series file\n",
14471447
"insar_ts, atr = readfile.read(insar_ts_file, datasetName='timeseries')\n",
14481448
"mask = readfile.read(os.path.join(mintpy_dir, 'maskTempCoh.h5'))[0]\n",
14491449
"print(f'reading timeseries from file: {insar_ts_file}')\n",
@@ -1454,7 +1454,7 @@
14541454
"date0, date1 = date_list[0], date_list[-1]\n",
14551455
"insar_dates = ptime.date_list2vector(date_list)[0]\n",
14561456
"\n",
1457-
"# spatial reference\n",
1457+
"# Spatial reference\n",
14581458
"coord = ut.coordinate(atr)\n",
14591459
"ref_site = sitedata['sites'][site]['gps_ref_site_name']\n",
14601460
"ref_gnss_obj = gnss_stns[ref_site]\n",
@@ -1470,33 +1470,33 @@
14701470
"for i, site_name in enumerate(site_names):\n",
14711471
" prog_bar.update(i+1, suffix=f'{site_name} {i+1}/{num_site}')\n",
14721472
"\n",
1473-
" ## read data\n",
1474-
" # recall gnss station displacements with outliers removed\n",
1473+
" ## Read data\n",
1474+
" # Recall gnss station displacements with outliers removed\n",
14751475
" gnss_obj = gnss_stns[site_name]\n",
14761476
" gnss_lalo = (gnss_obj.site_lat, gnss_obj.site_lon)\n",
14771477
"\n",
1478-
" # get relative LOS displacement on common dates\n",
1478+
" # Get relative LOS displacement on common dates\n",
14791479
" gnss_dates = np.array(sorted(list(set(gnss_obj.dates) & set(ref_gnss_obj.dates))))\n",
14801480
" gnss_dis = np.zeros(gnss_dates.shape, dtype=np.float32)\n",
14811481
" for i, date_i in enumerate(gnss_dates):\n",
14821482
" idx1 = np.where(gnss_obj.dates == date_i)[0][0]\n",
14831483
" idx2 = np.where(ref_gnss_obj.dates == date_i)[0][0]\n",
14841484
" gnss_dis[i] = gnss_obj.dis_los[idx1] - ref_gnss_obj.dis_los[idx2]\n",
14851485
" \n",
1486-
" # shift GNSS to zero-mean in time [for plotting purpose]\n",
1486+
" # Shift GNSS to zero-mean in time [for plotting purpose]\n",
14871487
" gnss_dis -= np.nanmedian(gnss_dis)\n",
14881488
"\n",
1489-
" # read InSAR\n",
1489+
" # Read InSAR\n",
14901490
" y, x = coord.geo2radar(gnss_lalo[0], gnss_lalo[1])[:2]\n",
14911491
" insar_dis = insar_ts[:, y, x] - ref_insar_dis\n",
1492-
" # apply a constant shift in time to fit InSAR to GNSS\n",
1492+
" # Apply a constant shift in time to fit InSAR to GNSS\n",
14931493
" comm_dates = sorted(list(set(gnss_dates) & set(insar_dates)))\n",
14941494
" if comm_dates:\n",
14951495
" insar_flag = [x in comm_dates for x in insar_dates]\n",
14961496
" gnss_flag = [x in comm_dates for x in gnss_dates]\n",
14971497
" insar_dis -= np.nanmedian(insar_dis[insar_flag] - gnss_dis[gnss_flag])\n",
14981498
"\n",
1499-
" ## plot figure\n",
1499+
" ## Plot figure\n",
15001500
" if gnss_dis.size > 0 and np.any(~np.isnan(insar_dis)):\n",
15011501
" fig, ax = plt.subplots(figsize=(10, 3))\n",
15021502
" ax.axhline(color='grey',linestyle='dashed', linewidth=2)\n",

methods/transient/Transient_Requirement_Validation.ipynb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
},
141141
"outputs": [],
142142
"source": [
143-
"# load packages\n",
143+
"# Load packages\n",
144144
"import copy\n",
145145
"import glob\n",
146146
"import math\n",
@@ -589,7 +589,7 @@
589589
" gnss_obj = gnss.get_gnss_class('UNR')(site = stn, data_dir = os.path.join(mintpy_dir,'GNSS'))\n",
590590
" gnss_obj.open()\n",
591591
" \n",
592-
" # count number of dates in time range\n",
592+
" # Count number of dates in time range\n",
593593
" gnss_obj.read_displacement()\n",
594594
" dates = gnss_obj.dates\n",
595595
" for i in range(insar_displacement.shape[0]):\n",
@@ -601,17 +601,17 @@
601601
" gnss_count = int(gnss_count[0])\n",
602602
" #print(gnss_count)\n",
603603
"\n",
604-
" # select GNSS stations based on data completeness, here we hope to select stations with data frequency of 1 day and no interruption\n",
604+
" # Select GNSS stations based on data completeness, here we hope to select stations with data frequency of 1 day and no interruption\n",
605605
" if range_days == gnss_count-1:\n",
606-
" #if start_date in dates and end_date in dates:\n",
606+
" # If start_date in dates and end_date in dates:\n",
607607
" disp_gnss_time_series,disp_gnss_time_series_std,site_latlon = gnss_obj.get_los_displacement(os.path.join(mintpy_dir,'inputs/geometryGeo.h5'),\n",
608608
" start_date=start_date.strftime('%Y%m%d'),\n",
609609
" end_date=end_date.strftime('%Y%m%d'))[1:4]\n",
610610
" x_value = round((site_latlon[1] - W)/lon_step)\n",
611611
" y_value = round((site_latlon[0] - N)/lat_step)\n",
612612
"\n",
613-
" #displacement from insar observation in the gnss station, averaged\n",
614-
" #Caution: If you expand the radius parameter farther than the bounding grid it will break. \n",
613+
" # Displacement from insar observation in the gnss station, averaged\n",
614+
" # Caution: If you expand the radius parameter farther than the bounding grid it will break. \n",
615615
" disp_insar = insar_displacement[i,\n",
616616
" y_value-pixel_radius:y_value+pixel_radius, \n",
617617
" x_value-pixel_radius:x_value+pixel_radius]\n",
@@ -749,7 +749,7 @@
749749
"metadata": {},
750750
"outputs": [],
751751
"source": [
752-
"# reference GNSS stations to GNSS reference site\n",
752+
"# Reference GNSS stations to GNSS reference site\n",
753753
"for i in displacement.index.get_level_values(0).unique():\n",
754754
" gnss_ref_site_name = random.choice(displacement.loc[i].index.unique())\n",
755755
" displacement.loc[i,'gnss_disp'] = displacement.loc[i,'gnss_disp'].values - displacement.loc[(i,gnss_ref_site_name),'gnss_disp']\n",
@@ -1020,7 +1020,8 @@
10201020
"outputs": [],
10211021
"source": [
10221022
"ratio = n_pass/n_all\n",
1023-
"thresthod = 0.683 \n",
1023+
"thresthod = 0.683\n",
1024+
"\n",
10241025
"#The assumed nature of Gaussian distribution gives a probability of 0.683 of being within one standard deviation.\n",
10251026
"success_or_fail = ratio>thresthod"
10261027
]
@@ -1654,7 +1655,7 @@
16541655
"name": "python",
16551656
"nbconvert_exporter": "python",
16561657
"pygments_lexer": "ipython3",
1657-
"version": "3.12.5"
1658+
"version": "3.12.8"
16581659
},
16591660
"toc-autonumbering": false,
16601661
"toc-showcode": false,

0 commit comments

Comments
 (0)