Source code for sdynpy.fileio.sdynpy_uff_datasets.sdynpy_uff_dataset_164
# -*- coding: utf-8 -*-"""UnitsThis dataset defines the unit system for the universal fileCopyright 2022 National Technology & Engineering Solutions of Sandia,LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.Government retains certain rights in this software.This program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <https://www.gnu.org/licenses/>."""from..sdynpy_uffimportUFFReadError
[docs]@classmethoddeffrom_uff_data_array(cls,data):# Transform from binary to asciidata=[line.decode()forlineindata]ds_164=cls()# Record 1: FORMAT(I10,20A1,I10)# Field 1 -- units code# = 1 - SI: Meter (newton)# = 2 - BG: Foot (pound f)# = 3 - MG: Meter (kilogram f)# = 4 - BA: Foot (poundal)# = 5 - MM: mm (milli newton)# = 6 - CM: cm (centi newton)# = 7 - IN: Inch (pound f)# = 8 - GM: mm (kilogram f)# = 9 - US: USER_DEFINED# = 10- MN: mm (newton)try:ds_164.units_code=int(data[0][0:10])exceptValueError:returnUFFReadError('Units Code (record 1 field 1) must be an integer!')# Field 2 -- units description (used for# documentation only)ds_164.units_description=data[0][10:30].strip()# Field 3 -- temperature mode# = 1 - absolute# = 2 - relativetry:ds_164.temperature_mode=int(data[0][30:40])exceptValueError:returnUFFReadError('Temperature Mode (record 1 field 3) must be an integer!')# Record 2: FORMAT(3D25.17)# Unit factors for converting universal file units to SI.# To convert from universal file units to SI divide by# the appropriate factor listed below.# Field 1 -- lengthtry:ds_164.length_conv=float(data[1][0:25])exceptValueError:returnUFFReadError('Length Conversion Factor (record 2 field 1) must be a floating point number')# Field 2 -- forcetry:ds_164.force_conv=float(data[1][25:50])exceptValueError:returnUFFReadError('Force Conversion Factor (record 2 field 2) must be a floating point number')# Field 3 -- temperaturetry:ds_164.temp_conv=float(data[1][50:75])exceptValueError:returnUFFReadError('Temperature Conversion Factor (record 2 field 3) must be a floating point number')# Field 4 -- temperature offset <-- Actually Record 3 field 1!try:ds_164.temp_offset=float(data[2][0:25])exceptValueError:returnUFFReadError('Temperature offset (record 4 field 1) must be a floating point number')returnds_164