Small changes.

parent c31fbf49
......@@ -2,7 +2,7 @@
Author: Emily Sturdivant, U.S. Geological Survey | esturdivant@usgs.gov
### Versions
[Version 1.0.0](https://code.usgs.gov/cmgp/bi-transect-extractor/tree/v1.0.0) was approved for release in July 2018. See what's changed since then in [the changelog](https://code.usgs.gov/cmgp/bi-transect-extractor/compare/v1.0.0...master?view=parallel&w=1).
[Version 1.0.0](https://code.usgs.gov/cmgp/bi-transect-extractor/tree/v1.0.0) was approved for release in July 2018. See what's changed since then in the [changelog](https://code.usgs.gov/cmgp/bi-transect-extractor/compare/v1.0.0...master?view=parallel&w=1).
## Overview
This package is used to calculate coastal geomorphology variables along shore-normal transects. The calculated variables are used as inputs for modeling geomorphology using a Bayesian Network (BN). The resulting input variables to the Geomorphology BN are described in the table below.
......
......@@ -43,7 +43,7 @@ sitemap = {
'Monomoy':{'region': 'Massachusetts', 'site': 'Monomoy',
'code': 'mon',
'MHW':0.39, 'MLW':-0.95,
'id_init_val':None,
'id_init_val':60000,
'morph_state': 22},
'CoastGuard':{'region': 'Massachusetts', 'site': 'CoastGuard',
'code': 'cg',
......@@ -90,6 +90,21 @@ sitemap = {
'MHW':0.26, 'MLW':-0.45,
'id_init_val':400000,
'morph_state': 11},
'Myrtle':{'region': 'Delmarva', 'site': 'Myrtle',
'code': 'myr',
'MHW':0.34, 'MLW':-0.59,
'id_init_val':130000,
'morph_state': 12},
'ShipShoal':{'region': 'Delmarva', 'site': 'ShipShoal',
'code': 'ship',
'MHW':0.34, 'MLW':-0.6,
'id_init_val':140000,
'morph_state': 12},
'Wreck':{'region': 'Delmarva', 'site': 'Wreck',
'code': 'wre',
'MHW':0.34, 'MLW':-0.6,
'id_init_val':150000,
'morph_state': 12},
}
########### Default Values ##########################
......
......@@ -17,6 +17,7 @@ from operator import add
import sys
import arcpy
import core.functions as fun
import time
"""
# General use functions
......@@ -1073,7 +1074,7 @@ def measure_Dist2Inlet(shoreline, in_trans, inletLines, tID_fld='sort_ID'):
df = df.append({tID_fld:tID, 'Dist2Inlet':mindist, 'lenR':lenR, 'lenL':lenL}, ignore_index=True)
# Alert if there is a large change (>300 m) in values between consecutive transects
try:
dist_prev = pd.to_numeric(df.loc[df[tID_fld]==tID-1, 'Dist2Inlet'])
dist_prev = pd.to_numeric(df.loc[df[tID_fld]==tID-1, 'Dist2Inlet']) #df['Dist2Inlet'].loc[tID-1]
if any(abs(dist_prev - mindist) > 300):
print("CAUTION: Large change in Dist2Inlet values between transects {} ({} m) and {} ({} m).".format(tID-1, dist_prev, tID, mindist))
except:
......@@ -1353,14 +1354,13 @@ def JoinDFtoFC_2(df, in_fc, join_id, target_id=False, out_fc='', overwrite=True,
else:
arcpy.FeatureClassToFeatureClass_conversion(in_fc, arcpy.env.workspace, out_fc)
if overwrite:
fwa.DeleteExtraFields(out_fc, [target_id])
DeleteExtraFields(out_fc, [target_id])
# Use arcpy.da.ExtendTable() to join DF
if df.index.name in df.columns:
df.index.name = 'index'
df.index.name
# Convert DF to NP array
# Convert DF to NP array and get column names
df_filtered = df.select_dtypes(exclude=['object'])
arr = df_filtered.fillna(fill).to_records()
colnames = list(df_filtered.columns)
......@@ -1370,6 +1370,9 @@ def JoinDFtoFC_2(df, in_fc, join_id, target_id=False, out_fc='', overwrite=True,
arcpy.Delete_management(out_tbl) # delete if already exists
arcpy.da.NumPyArrayToTable(arr, out_tbl)
# Wait 5 seconds. We've been having problems with the next step that may have been caused by not pausing here.
time.sleep(5)
# Join table from DF to the copy of the extended transects.
arcpy.JoinField_management(out_fc, target_id, out_tbl, target_id, colnames)
if verbose:
......
......@@ -175,7 +175,7 @@
"# Copy feature class to dataframe.\n",
"trans_df = fwa.FCtoDF(extendedTrans, id_fld=tID_fld, extra_fields=extra_fields)\n",
"trans_df['DD_ID'] = trans_df[tID_fld] + sitevals['id_init_val']\n",
"trans_df.drop('Azimuth', axis=1, inplace=True)\n",
"trans_df.drop('Azimuth', axis=1, inplace=True, errors='ignore')\n",
"trans_df.rename_axis({\"BEARING\": \"Azimuth\"}, axis=1, inplace=True)\n",
"\n",
"# Get anthro fields and join to DF\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment