@@ -154,13 +154,18 @@ def load(self, info, raft=True):
154154 # if not project:
155155 # raise Exception(f'File {file} does not exist or cannot be read. Please check filename.')
156156 project = loadYAML (info )
157+
158+ # save directory of main yaml for use when reading linked files
159+ dir = os .path .dirname (os .path .abspath (info ))
160+
157161 else :
158162 project = info
163+ dir = ''
159164
160165 # look for site section
161166 # call load site method
162167 if 'site' in project :
163- self .loadSite (project ['site' ])
168+ self .loadSite (project ['site' ], dir = dir )
164169
165170 # look for design section
166171 # call load design method
@@ -954,10 +959,13 @@ def loadDesign(self, d, raft=True):
954959
955960 # ----- Site conditions processing functions -----
956961
957- def loadSite (self , site ):
962+ def loadSite (self , site , dir = '' ):
958963 '''Load site information from a dictionary or YAML file
959964 (specified by input). This should be the site portion of
960- the floating wind array ontology.'''
965+ the floating wind array ontology.
966+
967+ site : portion of project dict
968+ dir : optional directory of main yaml file'''
961969 # standard function to load dict if input is yaml
962970
963971 # load general information
@@ -969,7 +977,13 @@ def loadSite(self, site):
969977 # load bathymetry information, if provided
970978 if 'bathymetry' in site and site ['bathymetry' ]:
971979 if 'file' in site ['bathymetry' ] and site ['bathymetry' ]['file' ]: # make sure there was a file provided even if the key is there
972- self .loadBathymetry (site ['bathymetry' ]['file' ])
980+ filename = site ['bathymetry' ]['file' ]
981+
982+ # if it's a relative file location, specify the root directory
983+ if not os .path .isabs (filename ):
984+ filename = os .path .join (dir , filename )
985+ self .loadBathymetry (filename )
986+
973987 elif 'x' in site ['bathymetry' ] and 'y' in site ['bathymetry' ]:
974988 self .grid_x = np .array (site ['bathymetry' ]['x' ])
975989 self .grid_y = np .array (site ['bathymetry' ]['y' ])
0 commit comments