Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.0 #27

Merged
merged 5 commits into from
Aug 25, 2023
Merged

V3.0 #27

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,6 @@ SeasonalClimateFiles
*.csv
*.md5

#files created from running tests
tests/Bpstatus/BP_Status/
tests/Bpstatus/.*
tests/CreateHDF5/BP_CreateHDF5/
tests/CreateHDF5/.*
tests/ExtractArchive/BP_Extract/
tests/ExtractArchive/.*
tests/Stats/BP_Stats/
tests/Stats/.*
tests/ExtractFilterArchive/BP_Extract/
tests/ExtractFilterArchive/.*
tests/ExtractFilterRawData/BP_Extract/
tests/ExtractFilterRawData/.*
tests/MD5CheckSum/BP_Extract/
tests/MD5CheckSum/.*
tests/UlyssesAggregated/BP_Extract/
tests/UlyssesAggregated/.*
tests/UlyssesForward/BP_Extract/
tests/UlyssesForward/.*
tests/SingleSim/BP_Extract/
tests/SingleSim/.*


.coverage

# Aux files / build info / garbage
Expand Down
16 changes: 10 additions & 6 deletions bigplanet/bp_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def ExtractColumn(hf, k):
k : str
the name of the column that is to be extracted
Example:
k = 'earth_Obliquity_final'
The syntax of the column names is body_variable_aggregation
k = 'earth:Obliquity:final'
The syntax of the column names is body:variable:aggregation
the lists of aggregations (and how to call them) is as follows:

forward file data (forward), initial data (initial),
Expand Down Expand Up @@ -532,6 +532,7 @@ def Md5CheckSum(archivefile, ignore_corrupt=False):
md5file = name + ".md5"
# if it doesn't exist, we need to create it
if os.path.isfile(md5file) == False:
print(md5file+" file not found. Generating.")
with open(md5file, "w") as md5:
with open(bpa, "rb") as f:
file_hash = hashlib.md5()
Expand Down Expand Up @@ -560,11 +561,14 @@ def Md5CheckSum(archivefile, ignore_corrupt=False):
new_md5 = file_hash.hexdigest()
# print("MD5 from " + name + ".bpa: " + new_md5)
if md5_old == new_md5:
print("MD5 Checksum verified")
print("MD5 Checksum verified.")
else:
if ignore_corrupt == True:
print("WARNING: MD5 Checksum failed")
print("WARNING: MD5 Checksum failed!")
else:
print("ERROR: MD5 Checksum failed")
print("set flag --ignorecorrupt to still use corrupted data")
print("ERROR: MD5 Checksum failed!")
print("MD5 from " + md5file + ":", md5_old)
print("MD5 from " + name + ".bpa: " + new_md5)
print("set flag -ignorecorrupt to still use corrupted data")
print("INFO: MD5Checksumming is not functioning as ov v3.0, so you should probably set this flag!")
exit()
7 changes: 6 additions & 1 deletion bigplanet/bp_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,15 @@ def GetVplanetHelp():
):

option = line.strip("** ")
# print("Option:",option)
# print("Option: ",option,repr(count))
vplanet_dict[option] = {}
num = count + 1
while num != count:
#print("num,count: ",repr(num),repr(len(output)))
#print("Output[num]: ",repr(output[num]))
if (num >= len(output)):
print("ERROR: Unable to gather VPLanet help information!")
assert(0)
if "Type" in output[num]:
tp = output[num].rpartition("|")[-1].strip()
vplanet_dict[option]["Type"] = tp
Expand Down
41 changes: 0 additions & 41 deletions tests/Bpstatus/test_bpstatus.py

This file was deleted.

56 changes: 56 additions & 0 deletions tests/CreateHDF5/test_CreateHDF5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import multiprocessing as mp
import os
import pathlib
import subprocess
import sys
import warnings
import shutil

import numpy as np


def test_CreateHDF5():
# gets current path
path = pathlib.Path(__file__).parents[0].absolute()
sys.path.insert(1, str(path.parents[0]))

# gets the number of cores on the machine
cores = mp.cpu_count()
if cores == 1:
warnings.warn("There is only 1 core on the machine", stacklevel=3)
else:
# Remove anything from previous tests
if (path / "BP_CreateHDF5").exists():
shutil.rmtree(path / "BP_CreateHDF5")
if (path / ".BP_CreateHDF5").exists():
os.remove(path / ".BP_CreateHDF5")
if (path / ".BP_CreateHDF5_BPL").exists():
os.remove(path / ".BP_CreateHDF5_BPL")
if (path / "BP_CreateHDF5.bpa").exists():
os.remove(path / "BP_CreateHDF5.bpa")
if (path / "BP_CreateHDF5.md5").exists():
os.remove(path / "BP_CreateHDF5.md5")

# Run vspace
print("Running vspace.")
sys.stdout.flush()
subprocess.check_output(["vspace", "vspace.in"], cwd=path)

# Run multi-planet
print("Running MultiPlanet.")
sys.stdout.flush()
subprocess.check_output(["multiplanet", "vspace.in"], cwd=path)

# Run bigplanet
print("Running BigPlanet.")
sys.stdout.flush()
subprocess.check_output(["bigplanet", "bpl.in", "-a"], cwd=path)

file = path / "BP_CreateHDF5.bpa"

# checks if the bpl files exist
assert os.path.isfile(file) == True


if __name__ == "__main__":
test_CreateHDF5()
40 changes: 0 additions & 40 deletions tests/CreateHDF5/test_bpcreatehdf5.py

This file was deleted.

67 changes: 67 additions & 0 deletions tests/ExtractArchive/test_ExtractArchive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import multiprocessing as mp
import os
import pathlib
import subprocess
import sys
import warnings
import shutil
import numpy as np
import bigplanet as bp


def test_ExtractArchive():
# gets current path
path = pathlib.Path(__file__).parents[0].absolute()
sys.path.insert(1, str(path.parents[0]))

# gets the number of cores on the machine
cores = mp.cpu_count()
if cores == 1:
warnings.warn("There is only 1 core on the machine", stacklevel=3)
else:
# Remove anything from previous tests
if (path / "BP_Extract").exists():
shutil.rmtree(path / "BP_Extract")
if (path / ".BP_Extract").exists():
os.remove(path / ".BP_Extract")
if (path / ".BP_Extract_BPL").exists():
os.remove(path / ".BP_Extract_BPL")
if (path / "BP_Extract.bpa").exists():
os.remove(path / "BP_Extract.bpa")
if (path / "../BP_Extract.md5").exists():
os.remove(path / "../BP_Extract.md5")
if (path / "BP_Extract.md5").exists():
os.remove(path / "BP_Extract.md5")

# Run vspace
print("Running vspace.")
sys.stdout.flush()
subprocess.check_output(["vspace", "vspace.in"], cwd=path)

# Run multi-planet
print("Running MultiPlanet.")
sys.stdout.flush()
subprocess.check_output(["multiplanet", "vspace.in"], cwd=path)

# Run bigplanet
print("Running BigPlanet.")
sys.stdout.flush()

######## SOMETHING IS WRONG WITH MD5CHECKSUMS! #######
subprocess.check_output(["bigplanet", "-ignorecorrupt", "bpl.in", "-a"], cwd=path)

file = bp.BPLFile(path / "BP_Extract.bpa")

earth_Instellation_final = bp.ExtractColumn(
file, "earth:Instellation:final"
)
sun_RotPer_initial = bp.ExtractColumn(file, "sun:RotPer:initial")

assert np.isclose(earth_Instellation_final[0], 1367.635318)
assert np.isclose(earth_Instellation_final[1], 341.90883)

assert np.isclose(sun_RotPer_initial[0], 86400.0)


if __name__ == "__main__":
test_ExtractArchive()
50 changes: 0 additions & 50 deletions tests/ExtractArchive/test_bpextract.py

This file was deleted.

Loading
Loading