Skip to content

Commit 7def6b7

Browse files
committed
remove some redundant stuff for delete compare function
1 parent 6d59768 commit 7def6b7

1 file changed

Lines changed: 0 additions & 361 deletions

File tree

oceanval/__init__.py

Lines changed: 0 additions & 361 deletions
Original file line numberDiff line numberDiff line change
@@ -128,26 +128,6 @@ def fix_toc(concise=True, data_dir=None, out_dir=None, info = False):
128128
i_chapter += 1
129129

130130

131-
#def fix_toc_comparison():
132-
# book_dir = "oceanval_comparison"
133-
#
134-
# out = f"{book_dir}/compare/_toc.yml"
135-
# # write line by line to out
136-
# with open(out, "w") as f:
137-
# # "format: jb-book"
138-
# x = f.write("format: jb-book\n")
139-
# x = f.write("root: intro\n")
140-
# x = f.write("parts:\n")
141-
# x = f.write(f"- caption: Comparisons with gridded surface observations\n")
142-
# x = f.write(" chapters:\n")
143-
# x = f.write(f" - file: notebooks/comparison_bias.ipynb\n")
144-
# x = f.write(f" - file: notebooks/comparison_spatial.ipynb\n")
145-
# x = f.write(f" - file: notebooks/comparison_seasonal.ipynb\n")
146-
# x = f.write(f" - file: notebooks/comparison_regional.ipynb\n")
147-
# x = f.write(f"- caption: Comparisons with point observations\n")
148-
# x = f.write(" chapters:\n")
149-
# x = f.write(f" - file: notebooks/comparison_point_surface.ipynb\n")
150-
151131

152132
def validate(
153133
lon_lim=None,
@@ -739,347 +719,6 @@ def rebuild(data_dir="."):
739719
__version__ = "999"
740720

741721

742-
#def compare(model_dict=None, view=True, ask = True):
743-
# """
744-
# Compare pre-validated simulations.
745-
# This function will compare the validation output from two simulations.
746-
#
747-
# Parameters
748-
# ----------
749-
# model_dict : dict
750-
# A dictionary of model names and the paths to the validation output. Default is None.
751-
# Example: {"model1": "/path/to/model1", "model2": "/path/to/model2"}
752-
# If the models have different grids, put the model with the smallest grid first.
753-
# view : bool
754-
# Default is True. Open the comparison report in a web browser after it is generated.
755-
# ask : bool
756-
# Default is True. If the oceanval_comparison directory already exists, ask the user if
757-
#
758-
# """
759-
#
760-
# for key in model_dict.keys():
761-
# # check that the path exists
762-
# if not os.path.exists(model_dict[key]):
763-
# raise ValueError(f"Path {model_dict[key]} does not exist")
764-
# # convert to an absolute path
765-
# model_dict[key] = os.path.abspath(model_dict[key])
766-
#
767-
# if os.path.exists("oceanval_comparison"):
768-
# # get user input to decide if it should be removed
769-
# if ask:
770-
# user_input = input(
771-
# "oceanval_comparison directory already exists. This will be emptied and replaced. Do you want to proceed? (y/n): "
772-
# )
773-
# if user_input.lower() != "y":
774-
# print("Exiting")
775-
# return None
776-
#
777-
# while True:
778-
# files = glob.glob("oceanval_comparison/**/**/**", recursive=True)
779-
# # list all files in oceanval_comparison, recursively
780-
# for ff in files:
781-
# if ff.startswith("oceanval_comparison"):
782-
# try:
783-
# os.remove(ff)
784-
# except:
785-
# pass
786-
# files = glob.glob("oceanval_comparison/**/**/**", recursive=True)
787-
# # only list files
788-
# files = [x for x in files if os.path.isfile(x)]
789-
# if len(files) == 0:
790-
# break
791-
# else:
792-
# print("Exiting")
793-
# return None
794-
#
795-
# if not os.path.exists("oceanval_comparison/compare"):
796-
# # create directory recursively
797-
# os.makedirs("oceanval_comparison/compare")
798-
#
799-
# # copy the pml logo
800-
# shutil.copyfile(
801-
# importlib.resources.files(__name__).joinpath("data/pml_logo.jpg"),
802-
# "oceanval_comparison/pml_logo.jpg",
803-
# )
804-
#
805-
# # move toc etc to oceanval_comparison/compare
806-
#
807-
# data_path = importlib.resources.files(__name__).joinpath("data/_toc.yml")
808-
#
809-
# out = "oceanval_comparison/compare/" + os.path.basename(data_path)
810-
# shutil.copyfile(data_path, out)
811-
#
812-
# fix_toc_comparison()
813-
#
814-
# data_path = importlib.resources.files(__name__).joinpath("data/requirements.txt")
815-
#
816-
# out = "oceanval_comparison/compare/" + os.path.basename(data_path)
817-
#
818-
# shutil.copyfile(data_path, out)
819-
#
820-
# data_path = importlib.resources.files(__name__).joinpath("data/intro.md")
821-
#
822-
# out = "oceanval_comparison/compare/" + os.path.basename(data_path)
823-
#
824-
# shutil.copyfile(data_path, out)
825-
#
826-
# # copy config
827-
#
828-
# data_path = importlib.resources.files(__name__).joinpath("data/_config.yml")
829-
#
830-
# out = "oceanval_comparison/compare/" + os.path.basename(data_path)
831-
#
832-
# shutil.copyfile(data_path, out)
833-
# # read in out and change some values
834-
# with open(out, "r") as file:
835-
# filedata = file.read()
836-
# # Replace the target string
837-
# filedata = filedata.replace("oceanval_report", "../oceanval_comparison")
838-
# # Write the file out again
839-
# with open(out, "w") as file:
840-
# file.write(filedata)
841-
#
842-
# # copy the comparison_seasonal notebook
843-
#
844-
# # make sure the directory exists
845-
#
846-
# if not os.path.exists("oceanval_comparison/compare/notebooks"):
847-
# # create directory recursively
848-
# os.makedirs("oceanval_comparison/compare/notebooks")
849-
#
850-
# file1 = importlib.resources.files(__name__).joinpath(
851-
# "data/comparison_seasonal.ipynb"
852-
# )
853-
# if (
854-
# len(
855-
# glob.glob(
856-
# "oceanval_comparison/compare/notebooks/*comparison_seasonal.ipynb"
857-
# )
858-
# )
859-
# == 0
860-
# ):
861-
# shutil.copyfile(
862-
# file1, "oceanval_comparison/compare/notebooks/comparison_seasonal.ipynb"
863-
# )
864-
#
865-
# model_dict_str = str(model_dict)
866-
#
867-
# with open(
868-
# "oceanval_comparison/compare/notebooks/comparison_seasonal.ipynb", "r"
869-
# ) as file:
870-
# filedata = file.read()
871-
#
872-
# # Replace the target string
873-
# filedata = filedata.replace("model_dict_str", model_dict_str)
874-
#
875-
# # Write the file out again
876-
#
877-
# with open(
878-
# "oceanval_comparison/compare/notebooks/comparison_seasonal.ipynb", "w"
879-
# ) as file:
880-
# file.write(filedata)
881-
#
882-
# # now sort out the comparison_spatial notebook
883-
#
884-
# file1 = importlib.resources.files(__name__).joinpath(
885-
# "data/comparison_spatial.ipynb"
886-
# )
887-
# if (
888-
# len(
889-
# glob.glob("oceanval_comparison/compare/notebooks/*comparison_spatial.ipynb")
890-
# )
891-
# == 0
892-
# ):
893-
# shutil.copyfile(
894-
# file1, "oceanval_comparison/compare/notebooks/comparison_spatial.ipynb"
895-
# )
896-
#
897-
# model_dict_str = str(model_dict)
898-
#
899-
# with open(
900-
# "oceanval_comparison/compare/notebooks/comparison_spatial.ipynb", "r"
901-
# ) as file:
902-
# filedata = file.read()
903-
#
904-
# # Replace the target string
905-
# filedata = filedata.replace("model_dict_str", model_dict_str)
906-
#
907-
# # Write the file out again
908-
#
909-
# with open(
910-
# "oceanval_comparison/compare/notebooks/comparison_spatial.ipynb", "w"
911-
# ) as file:
912-
# file.write(filedata)
913-
#
914-
# # move the regional book
915-
#
916-
# file1 = importlib.resources.files(__name__).joinpath(
917-
# "data/comparison_regional.ipynb"
918-
# )
919-
# if (
920-
# len(
921-
# glob.glob(
922-
# "oceanval_comparison/compare/notebooks/*comparison_regional.ipynb"
923-
# )
924-
# )
925-
# == 0
926-
# ):
927-
# shutil.copyfile(
928-
# file1, "oceanval_comparison/compare/notebooks/comparison_regional.ipynb"
929-
# )
930-
#
931-
# model_dict_str = str(model_dict)
932-
#
933-
# with open(
934-
# "oceanval_comparison/compare/notebooks/comparison_regional.ipynb", "r"
935-
# ) as file:
936-
# filedata = file.read()
937-
#
938-
# # Replace the target string
939-
# filedata = filedata.replace("model_dict_str", model_dict_str)
940-
#
941-
# # Write the file out again
942-
#
943-
# with open(
944-
# "oceanval_comparison/compare/notebooks/comparison_regional.ipynb", "w"
945-
# ) as file:
946-
# file.write(filedata)
947-
#
948-
# # now to comparison_bias
949-
#
950-
# file1 = importlib.resources.files(__name__).joinpath("data/comparison_bias.ipynb")
951-
#
952-
# if (
953-
# len(glob.glob("oceanval_comparison/compare/notebooks/*comparison_bias.ipynb"))
954-
# == 0
955-
# ):
956-
# shutil.copyfile(
957-
# file1, "oceanval_comparison/compare/notebooks/comparison_bias.ipynb"
958-
# )
959-
#
960-
# model_dict_str = str(model_dict)
961-
#
962-
# with open(
963-
# "oceanval_comparison/compare/notebooks/comparison_bias.ipynb", "r"
964-
# ) as file:
965-
# filedata = file.read()
966-
#
967-
# # Replace the target string
968-
# filedata = filedata.replace("model_dict_str", model_dict_str)
969-
#
970-
# # Write the file out again
971-
#
972-
# with open(
973-
# "oceanval_comparison/compare/notebooks/comparison_bias.ipynb", "w"
974-
# ) as file:
975-
# file.write(filedata)
976-
#
977-
# # figure out if both simulations have point data
978-
#
979-
# i = 0
980-
#
981-
# if i == 0:
982-
# for ss in ["surface"]:
983-
# file1 = importlib.resources.files(__name__).joinpath(
984-
# "data/comparison_point.ipynb"
985-
# )
986-
#
987-
# if (
988-
# len(
989-
# glob.glob(
990-
# f"oceanval_comparison/compare/notebooks/*comparison_point_{ss}.ipynb"
991-
# )
992-
# )
993-
# == 0
994-
# ):
995-
# shutil.copyfile(
996-
# file1,
997-
# f"oceanval_comparison/compare/notebooks/comparison_point_{ss}.ipynb",
998-
# )
999-
#
1000-
# model_dict_str = str(model_dict)
1001-
#
1002-
# with open(
1003-
# f"oceanval_comparison/compare/notebooks/comparison_point_{ss}.ipynb",
1004-
# "r",
1005-
# ) as file:
1006-
# filedata = file.read()
1007-
#
1008-
# # Replace the target string
1009-
# filedata = filedata.replace("model_dict_str", model_dict_str)
1010-
#
1011-
# # Write the file out again
1012-
#
1013-
# with open(
1014-
# f"oceanval_comparison/compare/notebooks/comparison_point_{ss}.ipynb",
1015-
# "w",
1016-
# ) as file:
1017-
# file.write(filedata)
1018-
# # replace layer in the notebook with ss
1019-
# with open(
1020-
# f"oceanval_comparison/compare/notebooks/comparison_point_{ss}.ipynb",
1021-
# "r",
1022-
# ) as file:
1023-
# filedata = file.read()
1024-
#
1025-
# # Replace the target string
1026-
# filedata = filedata.replace("layer", ss)
1027-
#
1028-
# # Write the file out again
1029-
#
1030-
# with open(
1031-
# f"oceanval_comparison/compare/notebooks/comparison_point_{ss}.ipynb",
1032-
# "w",
1033-
# ) as file:
1034-
# file.write(filedata)
1035-
#
1036-
# # sync the notebooks
1037-
#
1038-
# os.system(
1039-
# "jupytext --set-formats ipynb,py:percent oceanval_comparison/compare/notebooks/*.ipynb"
1040-
# )
1041-
#
1042-
# add_chunks()
1043-
#
1044-
# # replace the test status in the notebooks
1045-
# books = glob.glob("oceanval_comparison/compare/notebooks/*.py")
1046-
# for book in books:
1047-
# with open(book, "r") as file:
1048-
# filedata = file.read()
1049-
#
1050-
# # Replace the target string
1051-
# filedata = filedata.replace("the_test_status", "False")
1052-
#
1053-
# # Write the file out again
1054-
# with open(book, "w") as file:
1055-
# file.write(filedata)
1056-
#
1057-
# # fix the chunks
1058-
# os.system("jupytext --sync oceanval_comparison/compare/notebooks/*.ipynb")
1059-
#
1060-
# # loop through notebooks and change fast_plot_value to fast_plot
1061-
#
1062-
# for ff in glob.glob("oceanval_comparison/compare/notebooks/*.ipynb"):
1063-
# with open(ff, "r") as file:
1064-
# filedata = file.read()
1065-
#
1066-
# # Replace the target string
1067-
# filedata = filedata.replace("fast_plot_value", "False")
1068-
#
1069-
# # Write the file out again
1070-
# with open(ff, "w") as file:
1071-
# file.write(filedata)
1072-
#
1073-
# os.system("jupyter-book build oceanval_comparison/compare/")
1074-
# import webbrowser
1075-
#
1076-
# if view:
1077-
# webbrowser.open(
1078-
# "file://"
1079-
# + os.path.abspath("oceanval_comparison/compare/_build/html/index.html")
1080-
# )
1081-
#
1082-
1083722
import tempfile
1084723

1085724

0 commit comments

Comments
 (0)