Skip to content

Commit e64fd9d

Browse files
Add storage for raw data into project file. Version bump
1 parent a83e4df commit e64fd9d

File tree

3 files changed

+90
-6
lines changed

3 files changed

+90
-6
lines changed

LoopProjectFile/DataCollection.py

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ def SetDefaultConfiguration(root, verbose=False):
683683
return response
684684

685685

686-
# Extract data collection (map2loop) sources settings
686+
# Extract data collection (map2loop) source urls
687687
def GetSources(root, verbose=False):
688688
response = {"errorFlag": False}
689689
resp = GetDataCollectionGroup(root)
@@ -710,7 +710,7 @@ def GetSources(root, verbose=False):
710710
return response
711711

712712

713-
# Set data collection (map2loop) configuration settings
713+
# Set data collection (map2loop) source urls
714714
def SetSources(root, data, verbose=False):
715715
"""
716716
**SetConfiguration** - Saves the settings for the data collection step
@@ -756,7 +756,7 @@ def SetSources(root, data, verbose=False):
756756
return response
757757

758758

759-
# Create Default data collection (map2loop) source settings
759+
# Create Default data collection (map2loop) source urls
760760
def SetDefaultSources(root, verbose=False):
761761
response = {"errorFlag": False}
762762
resp = GetDataCollectionGroup(root)
@@ -774,3 +774,81 @@ def SetDefaultSources(root, verbose=False):
774774
dcGroup.metadataUrl = ""
775775
dcGroup.sourceTags = ""
776776
return response
777+
778+
779+
# Extract data collection (map2loop) raw data
780+
def GetRawSourceData(root, verbose=False):
781+
response = {"errorFlag": False}
782+
resp = GetDataCollectionGroup(root)
783+
if resp["errorFlag"]:
784+
response = resp
785+
else:
786+
dcGroup = resp["value"]
787+
data = {}
788+
if "structureRawData" in dcGroup.ncattrs():
789+
data["structureRawData"] = dcGroup.structureRawData
790+
if "geologyRawData" in dcGroup.ncattrs():
791+
data["geologyRawData"] = dcGroup.geologyRawData
792+
if "faultRawData" in dcGroup.ncattrs():
793+
data["faultRawData"] = dcGroup.faultRawData
794+
if "foldRawData" in dcGroup.ncattrs():
795+
data["foldRawData"] = dcGroup.foldRawData
796+
response["value"] = data
797+
return response
798+
799+
800+
# Set data collection raw data
801+
def SetRawSourceData(root, data, verbose=False):
802+
"""
803+
**SetConfiguration** - Saves the settings for the data collection step
804+
805+
Parameters
806+
----------
807+
rootGroup: netCDF4.Group
808+
The root group node of a Loop Project File
809+
data: dictionary {str: str,...}
810+
A dictionary with the data colletion settings
811+
verbose: bool
812+
A flag to indicate a higher level of console logging (more if True)
813+
814+
Returns
815+
-------
816+
dict {"errorFlag", "errorString"}
817+
errorString exist and contains error message only when errorFlag is
818+
True
819+
820+
"""
821+
response = {"errorFlag": False}
822+
resp = GetDataCollectionGroup(root)
823+
if resp["errorFlag"]:
824+
# Create Structural Models Group and add data shape based on project extents
825+
dcGroup = root.createGroup("DataCollection")
826+
else:
827+
dcGroup = resp["value"]
828+
829+
if (data.contains("structureRawData")):
830+
dcGroup.structureRawData = data.structureRawData
831+
if (data.contains("geologyRawData")):
832+
dcGroup.geologyRawData = data.geologyRawData
833+
if (data.contains("faultRawData")):
834+
dcGroup.faultRawData = data.faultRawData
835+
if (data.contains("foldRawData")):
836+
dcGroup.foldRawData = data.foldRawData
837+
return response
838+
839+
840+
# Create blank data collection data
841+
def SetDefaultRawSourceData(root, verbose=False):
842+
response = {"errorFlag": False}
843+
resp = GetDataCollectionGroup(root)
844+
if resp["errorFlag"]:
845+
dcGroup = root.createGroup("DataCollection")
846+
else:
847+
dcGroup = resp["value"]
848+
849+
dcGroup.structureRawData = ""
850+
dcGroup.geologyRawData = ""
851+
dcGroup.faultRawData = ""
852+
dcGroup.foldRawData = ""
853+
854+
return response

LoopProjectFile/LoopProjectFile.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def CreateBasic(filename):
9292
response = Version.SetVersion(rootGroup, version=Version.LoopVersion())
9393
if not response['errorFlag']:
9494
response = DataCollection.SetDefaultSources(rootGroup)
95+
if not response['errorFlag']:
96+
response = DataCollection.SetDefaultRawSourceData(rootGroup)
9597
if not response['errorFlag']:
9698
response = DataCollection.SetDefaultConfiguration(rootGroup)
9799
if not response['errorFlag']:
@@ -279,6 +281,8 @@ def Set(filename, element, **kwargs):
279281
response = DataCollection.SetConfiguration(root, **kwargs)
280282
elif element == "dataCollectionSources":
281283
response = DataCollection.SetSources(root, **kwargs)
284+
elif element == "dataCollectionRawSourceData":
285+
response = DataCollection.SetRawSourceData(root, **kwargs)
282286
elif element == "eventRelationships":
283287
response = ExtractedInformation.SetEventRelationships(root, **kwargs)
284288
elif element == "structuralModelsConfig":
@@ -390,6 +394,8 @@ def Get(filename, element, **kwargs):
390394
response = DataCollection.GetConfiguration(root, **kwargs)
391395
elif element == "dataCollectionSources":
392396
response = DataCollection.GetSources(root, **kwargs)
397+
elif element == "dataCollectionRawSourceData":
398+
response = DataCollection.GetRawSourceData(root, **kwargs)
393399
elif element == "eventRelationships":
394400
response = ExtractedInformation.GetEventRelationships(root, **kwargs)
395401
elif element == "structuralModelsConfig":

LoopProjectFile/Version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.22"
1+
__version__ = "0.0.23"
22

33

44
# Current Loop Project File Version
@@ -68,8 +68,8 @@ def GetVersion(rootGroup):
6868
value is a [int,int,int] of the version of this project file
6969
7070
"""
71-
if CheckVersionValid(rootGroup, True):
72-
return {"errorFlag": False, "value": [rootGroup.loopMajorVersion, rootGroup.loopMinorVersion, rootGroup.loopSubVersion]}
71+
if CheckVersionValid(rootGroup):
72+
return {"errorFlag": False, "value": list(map(int, [rootGroup.loopMajorVersion, rootGroup.loopMinorVersion, rootGroup.loopSubVersion]))}
7373
else:
7474
return {"errorFlag": True, "errorString": "No valid Version in Loop Project File"}
7575

0 commit comments

Comments
 (0)