substitute print by sys.write

This commit is contained in:
pilar 2021-01-07 17:33:55 -05:00
parent 592afe929d
commit 4faa02d18b
5 changed files with 22 additions and 12 deletions

View File

@ -259,7 +259,7 @@ class Surface:
rotation_base_matrix = np.matmul(rotation_base_matrix, base_matrix)
if rotation_base_matrix is None:
print('Error processing rotation base matrix')
sys.stderr.write('Warning: rotation base matrix returned None\n')
else:
for point in surface.points:
new_point = np.matmul(rotation_base_matrix, point)
@ -268,10 +268,10 @@ class Surface:
@staticmethod
def angle_between_vectors(vec_1, vec_2):
alpha = math.acos(np.dot(vec_1, vec_2) / np.linalg.norm(vec_1) / np.linalg.norm(vec_2))
if np.linalg.norm(vec_1) == 0 or np.linalg.norm(vec_2) == 0:
print('ERROR')
# todo: rise error
sys.stderr.write("Warning: impossible to calculate angle between planes' normal. Return 0\n")
return 0
alpha = math.acos(np.dot(vec_1, vec_2) / np.linalg.norm(vec_1) / np.linalg.norm(vec_2))
return alpha
def _is_almost_same_terrain(self, terrain_points, ground_points):
@ -474,7 +474,7 @@ class Surface:
return Surface(coordinates, remove_last=False)
except Exception as err:
print('Warning: intersecting surfaces', err)
sys.stderr.write('Warning: intersecting surfaces ' + str(err))
return None
@property

View File

@ -39,7 +39,8 @@ class City:
try:
input_reference = pyproj.CRS(self.srs_name) # Projected coordinate system from input data
except pyproj.exceptions.CRSError:
print('Invalid projection reference system, please check the input data. (e.g. in CityGML files: srs_name)')
sys.stderr.write('Invalid projection reference system, please check the input data. '
'(e.g. in CityGML files: srs_name)\n')
sys.exit()
transformer = Transformer.from_crs(input_reference, gps)
coordinates = transformer.transform(self.lower_corner[0], self.lower_corner[1])

View File

@ -3,6 +3,8 @@ CaPhysicsParameters import the construction and material information for Canada
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
import sys
from factories.physics_feeders.nrel_physics_interface import NrelPhysicsInterface
from factories.physics_feeders.helpers.ca_to_library_types import CaToLibraryTypes
@ -28,8 +30,9 @@ class CaPhysicsParameters(NrelPhysicsInterface):
for building in city.buildings:
archetype = self._search_archetype([building.function, building.year_of_construction])
if archetype is None:
print('Building ', building.name, 'has unknown archetype for building function: ', building.function,
'and building year of construction:', building.year_of_construction)
sys.stderr.write('Building ' + building.name + ' has unknown archetype for building function: ' +
building.function + ' and building year of construction: ' + building.year_of_construction +
'\n')
continue
self._assign_values(building, archetype)

View File

@ -7,6 +7,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
Contributors Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
import xmltodict
import sys
from city_model_structure.attributes.layer import Layer
from city_model_structure.attributes.material import Material
@ -41,9 +42,11 @@ class CercBasePhysicsParameters:
# ToDo: remove this in the future
# ToDo: Raise WrongArchetype if not all the surface types are defined for the given city_object
if archetype is None:
print('Building ', building.name, 'has unknown archetype for building type: ', building_type)
print('type: ', building_type, UsToLibraryTypes.yoc_to_standard(building.year_of_construction),
self._climate_zone)
sys.stderr.write('Building ' + building.name + ' has unknown archetype for building type: ' + building_type +
'\n')
sys.stderr.write('type: ' + building_type + ', ' +
UsToLibraryTypes.yoc_to_standard(building.year_of_construction) + ', ' + self._climate_zone +
'\n')
continue
building.average_storey_height = archetype['average_storey_height']['#text']

View File

@ -3,6 +3,8 @@ CaUsageParameters model the usage properties for a Canadian building
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
import sys
from factories.usage_feeders.hft_usage_interface import HftUsageInterface
from city_model_structure.attributes.usage_zone import UsageZone
@ -24,7 +26,8 @@ class CaUsageParameters(HftUsageInterface):
for building in city.buildings:
archetype = self._search_archetype(building.function)
if archetype is None:
print('Building ', building.name, 'has unknown archetype for building usage: ', building.function)
sys.stderr.write('Building ' + building.name + ' has unknown archetype for building usage: ' +
building.function + '\n')
continue
# todo: what to do with mix-usage usages from gml?
mix_usage = False