- Timestamp:
- Apr 4, 2014 10:04:58 AM (11 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f309303
- Parents:
- 92a8206
- Location:
- src/sans/dataloader/readers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/dataloader/readers/cansas_constants.py
re090c624 r9e2bc6c 193 193 "timestamp" : { 194 194 "variable" : META_DATA, 195 "storeas" : " content",195 "storeas" : "timestamp", 196 196 } 197 197 }, -
src/sans/dataloader/readers/cansas_reader.py
rea67541 r9e2bc6c 17 17 import os 18 18 import sys 19 import datetime 19 20 from sans.dataloader.data_info import Data1D 20 21 from sans.dataloader.data_info import Collimation … … 428 429 cs_values.current_level, attr, data1d, \ 429 430 tagname, node_value, cs_values.ns_optional) 430 431 # If the value is a timestamp, convert to a datetime object 432 elif cs_values.ns_datatype == "timestamp": 433 if node_value is None or node_value.isspace(): 434 pass 435 else: 436 try: 437 node_value = \ 438 datetime.datetime.fromtimestamp(node_value) 439 except ValueError: 440 node_value = None 431 441 # If appending to a dictionary (meta_data | run_name) 432 442 # make sure the key is unique … … 516 526 main_node = doc.createElement("SASroot") 517 527 518 doc = self.setProcessingInstructions(doc, datainfo.meta_data[PREPROCESS]) 528 doc = self.setProcessingInstructions(doc, \ 529 datainfo.meta_data.get(PREPROCESS, {})) 519 530 main_node.setAttribute("version", self.cansas_version) 520 531 main_node.setAttribute("xmlns", ns) … … 532 543 533 544 write_node(doc, entry_node, "Title", datainfo.title) 545 if datainfo.run == None or datainfo.run == []: 546 RUN_NAME_DEFAULT = "None" 547 datainfo.run.append(RUN_NAME_DEFAULT) 548 datainfo.run_name[RUN_NAME_DEFAULT] = RUN_NAME_DEFAULT 534 549 for item in datainfo.run: 535 550 runname = {} … … 567 582 spectrum = datainfo.trans_spectrum[i] 568 583 node = doc.createElement("SAStransmission_spectrum") 584 node.setAttribute("name", spectrum.name) 585 if isinstance(spectrum.timestamp, datetime.datetime): 586 node.setAttribute("timestamp", spectrum.timestamp) 569 587 entry_node.appendChild(node) 570 588 for i in range(len(spectrum.wavelength)): … … 632 650 source.setAttribute("name", str(datainfo.source.name)) 633 651 instr.appendChild(source) 652 if datainfo.source.radiation == None or datainfo.source.radiation == '': 653 datainfo.source.radiation = "neutron" 634 654 write_node(doc, source, "radiation", datainfo.source.radiation) 635 655 … … 663 683 664 684 # Collimation 685 if datainfo.collimation == [] or datainfo.collimation == None: 686 coll = Collimation() 687 datainfo.collimation.append(coll) 665 688 for item in datainfo.collimation: 666 689 coll = doc.createElement("SAScollimation") … … 696 719 697 720 # Detectors 721 if datainfo.detector == None or datainfo.detector == []: 722 det = Detector() 723 det.name = "" 724 datainfo.detector.append(det) 725 698 726 for item in datainfo.detector: 699 727 det = doc.createElement("SASdetector") … … 808 836 return minidomObject 809 837 810
Note: See TracChangeset
for help on using the changeset viewer.