From eda818703935c14b45808f90b088982a1745f034 Mon Sep 17 00:00:00 2001 From: "James S. Halgren" Date: Mon, 13 Nov 2023 16:11:44 -0600 Subject: [PATCH] Drop the extraneous files and synchronize removed filenamelist.txt in test folder removed urlgennwm.py in test folder added `write_to_file` var changed function call from `generate_urls` to `generate_urls_operational` --- test/filenamelist.txt | 8 - test/test_analysisAssim.py | 10 +- test/test_analysisAssimExtend.py | 10 +- test/test_analysisAssimExtendNoDa.py | 10 +- test/test_analysisAssimHawaii.py | 10 +- test/test_analysisAssimHawaiiNoDa.py | 10 +- test/test_analysisAssimNoDa.py | 10 +- test/test_analysisAssimPuertorico.py | 10 +- test/test_analysisAssimPuertoricoNoDa.py | 10 +- test/test_forcingAnalysisAssim.py | 10 +- test/test_forcingAnalysisAssimExtend.py | 10 +- test/test_forcingAnalysisAssimHawaii.py | 10 +- test/test_forcingAnalysisAssimPuertorico.py | 10 +- test/test_forcingMediumRange.py | 10 +- test/test_forcingShortRange.py | 10 +- test/test_forcingShortRangeAssimHawaii.py | 10 +- test/test_forcingShortRangeAssimPuertorico.py | 10 +- test/test_longRangeMem1.py | 10 +- test/test_longRangeMem2.py | 10 +- test/test_longRangeMem3.py | 10 +- test/test_longRangeMem4.py | 10 +- test/test_mediumRangeMem1.py | 10 +- test/test_mediumRangeMem2.py | 10 +- test/test_mediumRangeMem3.py | 10 +- test/test_mediumRangeMem4.py | 10 +- test/test_mediumRangeMem5.py | 10 +- test/test_mediumRangeMem6.py | 10 +- test/test_mediumRangeMemNoDa.py | 10 +- test/test_mediumRangeNoDa.py | 10 +- test/test_shortRange.py | 10 +- test/test_shortRangeAssimHawaii.py | 10 +- test/test_shortRangeAssimPuertorico.py | 10 +- test/test_shortRangeAssimPuertoricoNoDa.py | 10 +- test/urlgennwm.py | 531 ------------------ 34 files changed, 192 insertions(+), 667 deletions(-) delete mode 100644 test/filenamelist.txt delete mode 100644 test/urlgennwm.py diff --git a/test/filenamelist.txt b/test/filenamelist.txt deleted file mode 100644 index ed76c90..0000000 --- a/test/filenamelist.txt +++ /dev/null @@ -1,8 +0,0 @@ -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f001.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f018.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f001.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f018.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f001.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f018.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f001.puertorico.nc -https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f018.puertorico.nc diff --git a/test/test_analysisAssim.py b/test/test_analysisAssim.py index cd571b4..54ca0e5 100644 --- a/test/test_analysisAssim.py +++ b/test/test_analysisAssim.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim(self): + def test_generate_urls_operational_for_analysis_assim(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim(self): runinput = 5 # Set to 5 for the analysis_assim folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimExtend.py b/test/test_analysisAssimExtend.py index f207cb3..90f099a 100644 --- a/test/test_analysisAssimExtend.py +++ b/test/test_analysisAssimExtend.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_extend(self): + def test_generate_urls_operational_for_analysis_assim_extend(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_extend(self): runinput = 6 # Set to 6 for the analysis_assim_extend folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_extend(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimExtendNoDa.py b/test/test_analysisAssimExtendNoDa.py index 4b72d08..4f30279 100644 --- a/test/test_analysisAssimExtendNoDa.py +++ b/test/test_analysisAssimExtendNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_extend_no_da(self): + def test_generate_urls_operational_for_analysis_assim_extend_no_da(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_extend_no_da(self): runinput = 7 # Set to 7 for the assim_extend_no_da folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_extend_no_da(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimHawaii.py b/test/test_analysisAssimHawaii.py index 4668a02..e858083 100644 --- a/test/test_analysisAssimHawaii.py +++ b/test/test_analysisAssimHawaii.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_hawaii(self): + def test_generate_urls_operational_for_analysis_assim_hawaii(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_hawaii(self): runinput = 5 # Set to 5 for the analysis_assim_hawaii folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_hawaii(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimHawaiiNoDa.py b/test/test_analysisAssimHawaiiNoDa.py index 92cd601..0bab2b6 100644 --- a/test/test_analysisAssimHawaiiNoDa.py +++ b/test/test_analysisAssimHawaiiNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_hawaii_no_da(self): + def test_generate_urls_operational_for_analysis_assim_hawaii_no_da(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_hawaii_no_da(self): runinput = 10 # Set to 10 for the analysis_assim_hawaii_no_da folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_hawaii_no_da(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimNoDa.py b/test/test_analysisAssimNoDa.py index 8fd8fe8..afb623b 100644 --- a/test/test_analysisAssimNoDa.py +++ b/test/test_analysisAssimNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_no_da(self): + def test_generate_urls_operational_for_analysis_assim_no_da(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_no_da(self): runinput = 10 # Set to 5 for the analysis_assim_no_da folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_no_da(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimPuertorico.py b/test/test_analysisAssimPuertorico.py index 38c3687..e0b62ae 100644 --- a/test/test_analysisAssimPuertorico.py +++ b/test/test_analysisAssimPuertorico.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_puertorico(self): + def test_generate_urls_operational_for_analysis_assim_puertorico(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_puertorico(self): runinput = 5 # Set to 5 for the analysis_assim_puertorico folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_puertorico(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_analysisAssimPuertoricoNoDa.py b/test/test_analysisAssimPuertoricoNoDa.py index affda16..e2f93f5 100644 --- a/test/test_analysisAssimPuertoricoNoDa.py +++ b/test/test_analysisAssimPuertoricoNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim_puertorico_no_da(self): + def test_generate_urls_operational_for_analysis_assim_puertorico_no_da(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim_puertorico_no_da(self): runinput = 10 # Set to 10 for the analysis_assim_puertorico_no_da folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim_puertorico_no_da(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingAnalysisAssim.py b/test/test_forcingAnalysisAssim.py index ceea74d..536f903 100644 --- a/test/test_forcingAnalysisAssim.py +++ b/test/test_forcingAnalysisAssim.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_analysis_assim(self): + def test_generate_urls_operational_for_forcing_analysis_assim(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_analysis_assim(self): runinput = 5 # Set to 5 for the forcing_analysis_assim folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_analysis_assim(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingAnalysisAssimExtend.py b/test/test_forcingAnalysisAssimExtend.py index 7ef762c..1576f28 100644 --- a/test/test_forcingAnalysisAssimExtend.py +++ b/test/test_forcingAnalysisAssimExtend.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_analysis_assim_extend(self): + def test_generate_urls_operational_for_forcing_analysis_assim_extend(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_analysis_assim_extend(self): runinput = 6 # Set to 6 for the forcing_analysis_assim_extend folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_analysis_assim_extend(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingAnalysisAssimHawaii.py b/test/test_forcingAnalysisAssimHawaii.py index c98db20..4584975 100644 --- a/test/test_forcingAnalysisAssimHawaii.py +++ b/test/test_forcingAnalysisAssimHawaii.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_analysis_assim_hawaii(self): + def test_generate_urls_operational_for_forcing_analysis_assim_hawaii(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_analysis_assim_hawaii(self): runinput = 5 # Set to 5 for the forcing_analysis_assim_hawaii folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_analysis_assim_hawaii(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingAnalysisAssimPuertorico.py b/test/test_forcingAnalysisAssimPuertorico.py index 3e8fcfe..f104fb7 100644 --- a/test/test_forcingAnalysisAssimPuertorico.py +++ b/test/test_forcingAnalysisAssimPuertorico.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_analysis_assim_puertorico(self): + def test_generate_urls_operational_for_forcing_analysis_assim_puertorico(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_analysis_assim_puertorico(self): runinput = 5 # Set to 5 for the forcing_analysis_assim_puertorico folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_analysis_assim_puertorico(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingMediumRange.py b/test/test_forcingMediumRange.py index 78e1165..b985d2f 100644 --- a/test/test_forcingMediumRange.py +++ b/test/test_forcingMediumRange.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_medium_range(self): + def test_generate_urls_operational_for_forcing_medium_range(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_medium_range(self): runinput = 2 # Set to 2 for the forcing_medium_range folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_medium_range(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingShortRange.py b/test/test_forcingShortRange.py index 0b8cf14..d089176 100644 --- a/test/test_forcingShortRange.py +++ b/test/test_forcingShortRange.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_short_range(self): + def test_generate_urls_operational_for_forcing_short_range(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_short_range(self): runinput = 1 # Set to 1 for the forcing_short_range folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_short_range(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingShortRangeAssimHawaii.py b/test/test_forcingShortRangeAssimHawaii.py index 1abb058..9a1ee20 100644 --- a/test/test_forcingShortRangeAssimHawaii.py +++ b/test/test_forcingShortRangeAssimHawaii.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_short_range_assim_hawaii(self): + def test_generate_urls_operational_for_forcing_short_range_assim_hawaii(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_short_range_assim_hawaii(self): runinput = 1 # Set to 1 for the forcing_short_range_assim_hawaii folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_short_range_assim_hawaii(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_forcingShortRangeAssimPuertorico.py b/test/test_forcingShortRangeAssimPuertorico.py index 273d7ac..91bdd4b 100644 --- a/test/test_forcingShortRangeAssimPuertorico.py +++ b/test/test_forcingShortRangeAssimPuertorico.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_forcing_short_range_assim_puerorico(self): + def test_generate_urls_operational_for_forcing_short_range_assim_puerorico(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_forcing_short_range_assim_puerorico(self): runinput = 1 # Set to 1 for the forcing_short_range_assim_puerorico folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_forcing_short_range_assim_puerorico(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_longRangeMem1.py b/test/test_longRangeMem1.py index 2f7fed8..d5bd923 100644 --- a/test/test_longRangeMem1.py +++ b/test/test_longRangeMem1.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_long_range_mem1(self): + def test_generate_urls_operational_for_long_range_mem1(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_long_range_mem1(self): runinput = 4 # Set to 4 for the long_range_mem1 folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_long_range_mem1(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_longRangeMem2.py b/test/test_longRangeMem2.py index a104b77..6d75a95 100644 --- a/test/test_longRangeMem2.py +++ b/test/test_longRangeMem2.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_long_range_mem2(self): + def test_generate_urls_operational_for_long_range_mem2(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_long_range_mem2(self): runinput = 4 # Set to 4 for the long_range_mem1 folder urlbaseinput = 2 meminput = 2 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_long_range_mem2(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_longRangeMem3.py b/test/test_longRangeMem3.py index 27f5cc7..6553050 100644 --- a/test/test_longRangeMem3.py +++ b/test/test_longRangeMem3.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_long_range_mem3(self): + def test_generate_urls_operational_for_long_range_mem3(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_long_range_mem3(self): runinput = 4 # Set to 4 for the long_range_mem3 folder urlbaseinput = 2 meminput = 3 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_long_range_mem3(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_longRangeMem4.py b/test/test_longRangeMem4.py index 52741e1..818ca17 100644 --- a/test/test_longRangeMem4.py +++ b/test/test_longRangeMem4.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_long_range_mem4(self): + def test_generate_urls_operational_for_long_range_mem4(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_long_range_mem4(self): runinput = 4 # Set to 4 for the long_range_mem4 folder urlbaseinput = 2 meminput = 4 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_long_range_mem4(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMem1.py b/test/test_mediumRangeMem1.py index a65baf7..ad5088c 100644 --- a/test/test_mediumRangeMem1.py +++ b/test/test_mediumRangeMem1.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_mem1(self): + def test_generate_urls_operational_for_medium_range_mem1(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_mem1(self): runinput = 2 # Set to 2 for the medium_range_mem1 folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_mem1(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMem2.py b/test/test_mediumRangeMem2.py index 8f44cf9..1630840 100644 --- a/test/test_mediumRangeMem2.py +++ b/test/test_mediumRangeMem2.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_mem2(self): + def test_generate_urls_operational_for_medium_range_mem2(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_mem2(self): runinput = 2 # Set to 2 for the medium_range_mem2 folder urlbaseinput = 2 meminput = 2 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_mem2(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMem3.py b/test/test_mediumRangeMem3.py index f48b537..7641740 100644 --- a/test/test_mediumRangeMem3.py +++ b/test/test_mediumRangeMem3.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_mem3(self): + def test_generate_urls_operational_for_medium_range_mem3(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_mem3(self): runinput = 2 # Set to 2 for the medium_range_mem3 folder urlbaseinput = 2 meminput = 3 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_mem3(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMem4.py b/test/test_mediumRangeMem4.py index 6bf6cb1..5e579af 100644 --- a/test/test_mediumRangeMem4.py +++ b/test/test_mediumRangeMem4.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_mem4(self): + def test_generate_urls_operational_for_medium_range_mem4(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_mem4(self): runinput = 2 # Set to 2 for the medium_range_mem4 folder urlbaseinput = 2 meminput = 4 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_mem4(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMem5.py b/test/test_mediumRangeMem5.py index c6342d2..246cfd6 100644 --- a/test/test_mediumRangeMem5.py +++ b/test/test_mediumRangeMem5.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_mem5(self): + def test_generate_urls_operational_for_medium_range_mem5(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_mem5(self): runinput = 2 # Set to 2 for the medium_range_mem5 folder urlbaseinput = 2 meminput = 5 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_mem5(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMem6.py b/test/test_mediumRangeMem6.py index f6fa3ab..cb4f2b9 100644 --- a/test/test_mediumRangeMem6.py +++ b/test/test_mediumRangeMem6.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_mem6(self): + def test_generate_urls_operational_for_medium_range_mem6(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_mem6(self): runinput = 2 # Set to 2 for the medium_range_mem6 folder urlbaseinput = 2 meminput = 6 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_mem6(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeMemNoDa.py b/test/test_mediumRangeMemNoDa.py index da21dc3..1f6e388 100644 --- a/test/test_mediumRangeMemNoDa.py +++ b/test/test_mediumRangeMemNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_medium_range_no_da(self): + def test_generate_urls_operational_for_medium_range_no_da(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_medium_range_no_da(self): runinput = 2 # Set to 2 for the medium_range_no_da folder urlbaseinput = 2 meminput = 4 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_medium_range_no_da(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_mediumRangeNoDa.py b/test/test_mediumRangeNoDa.py index 074c44c..f2410b5 100644 --- a/test/test_mediumRangeNoDa.py +++ b/test/test_mediumRangeNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_analysis_assim(self): + def test_generate_urls_operational_for_analysis_assim(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_analysis_assim(self): runinput = 3 # Set to 5 for the analysis_assim folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_analysis_assim(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_shortRange.py b/test/test_shortRange.py index 360698c..13a3cc6 100644 --- a/test/test_shortRange.py +++ b/test/test_shortRange.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_short_range(self): + def test_generate_urls_operational_for_short_range(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_short_range(self): runinput = 1 # Set to 1 for the short_range folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_short_range(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_shortRangeAssimHawaii.py b/test/test_shortRangeAssimHawaii.py index 477f783..f471d89 100644 --- a/test/test_shortRangeAssimHawaii.py +++ b/test/test_shortRangeAssimHawaii.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_short_range_assim_hawaii(self): + def test_generate_urls_operational_for_short_range_assim_hawaii(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_short_range_assim_hawaii(self): runinput = 1 # Set to 1 for the short_range_assim_hawaii folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_short_range_assim_hawaii(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_shortRangeAssimPuertorico.py b/test/test_shortRangeAssimPuertorico.py index f416c8b..d80b0c2 100644 --- a/test/test_shortRangeAssimPuertorico.py +++ b/test/test_shortRangeAssimPuertorico.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_short_range_assim_puertorico(self): + def test_generate_urls_operational_for_short_range_assim_puertorico(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_short_range_assim_puertorico(self): runinput = 1 # Set to 5 for the short_range_assim_puertorico folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_short_range_assim_puertorico(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/test_shortRangeAssimPuertoricoNoDa.py b/test/test_shortRangeAssimPuertoricoNoDa.py index bddbfbd..302de81 100644 --- a/test/test_shortRangeAssimPuertoricoNoDa.py +++ b/test/test_shortRangeAssimPuertoricoNoDa.py @@ -1,12 +1,12 @@ import os import unittest from urlgennwm import ( - generate_urls, -) # Import the generate_urls function from your script + generate_urls_operational, +) # Import the generate_urls_operational function from your script class TestGenerateURLs(unittest.TestCase): - def test_generate_urls_for_short_range_assim_puertorico_no_da(self): + def test_generate_urls_operational_for_short_range_assim_puertorico_no_da(self): # Define test input values start_date = "202201120000" end_date = "202201130000" @@ -17,9 +17,10 @@ def test_generate_urls_for_short_range_assim_puertorico_no_da(self): runinput = 11 # Set to 11 for the short_range_assim_puertorico_no_da folder urlbaseinput = 2 meminput = 1 + write_to_file = True # Call the function to generate URLs - generate_urls( + generate_urls_operational( start_date, end_date, fcst_cycle, @@ -29,6 +30,7 @@ def test_generate_urls_for_short_range_assim_puertorico_no_da(self): runinput, urlbaseinput, meminput, + write_to_file, ) # Check if the generated 'filenamelist.txt' file exists diff --git a/test/urlgennwm.py b/test/urlgennwm.py deleted file mode 100644 index 51178b7..0000000 --- a/test/urlgennwm.py +++ /dev/null @@ -1,531 +0,0 @@ -# from gevent import monkey -# monkey.patch_all() -from dateutil import rrule -from datetime import datetime, timezone -from itertools import product -import time -import os - -# from concurrent.futures import ThreadPoolExecutor -# import gevent -# import requests -from functools import partial -from tqdm import tqdm - -# def check_valid_urls(file_list, session=None): -# """if not session: -# session = requests.Session()""" -# t = tqdm(range(len(file_list))) -# check_url_part = partial(check_url, t) -# """with ThreadPoolExecutor(max_workers=10) as executor: -# valid_file_list = list(executor.map(check_url_part, file_list))""" -# valid_file_list = [gevent.spawn(check_url_part, file_name) for file_name in file_list] -# gevent.joinall(valid_file_list) -# return [file.get() for file in valid_file_list if file.get() is not None] - - -# def check_url(t, file): -# filename = file.split("/")[-1] -# try: -# with requests.head(file) as response: -# if response.status_code == 200: -# t.set_description(f"Found: {filename}") -# t.update(1) -# t.refresh() -# return file -# else: -# t.set_description(f"Not Found: {filename}") -# t.update(1) -# t.refresh() -# return None -# #response = session.head(file, timeout=1) -# except requests.exceptions.RequestException: -# t.set_description(f"Not Found: {filename}") -# t.update(1) -# t.refresh() -# return None -rundict = { - 1: "short_range", - 2: "medium_range", - 3: "medium_range_no_da", - 4: "long_range", - 5: "analysis_assim", - 6: "analysis_assim_extend", - 7: "analysis_assim_extend_no_da", - 8: "analysis_assim_long", - 9: "analysis_assim_long_no_da", - 10: "analysis_assim_no_da", - 11: "short_range_no_da", -} - -memdict = { - 1: "mem_1", - 2: "mem_2", - 3: "mem_3", - 4: "mem_4", - 5: "mem_5", - 6: "mem_6", - 7: "mem_7", -} - -vardict = {1: "channel_rt", 2: "land", 3: "reservoir", 4: "terrain_rt", 5: "forcing"} - -geodict = {1: "conus", 2: "hawaii", 3: "puertorico"} - - -def selectvar(vardict, varinput): - return vardict[varinput] - - -def selectgeo(geodict, geoinput): - return geodict[geoinput] - - -def selectrun(rundict, runinput): - return rundict[runinput] - - -def makename( - date, - run_name, - var_name, - fcst_cycle, - fcst_hour, - geography, - run_type, - fhprefix="", - runsuffix="", - varsuffix="", - run_typesuffix="", - urlbase_prefix="", -): - """This function handles preprocessed text and converts it into the applicable url to access the appropriate file.""" - - datetxt = f"nwm.{date.strftime('%Y%m%d')}" - foldertxt = f"{run_type}{run_typesuffix}" - filetxt = f"nwm.t{fcst_cycle:02d}z.{run_name}{runsuffix}.{var_name}{varsuffix}.{fhprefix}{fcst_hour:03d}.{geography}.nc" - return f"{urlbase_prefix}{datetxt}/{foldertxt}/{filetxt}" - - -# setting run_type -def run_type(runinput, varinput, geoinput, default=""): - """This function takes the numeric command line input and converts to the text used in the url.""" - - if varinput == 5: # if forcing - if runinput == 5 and geoinput == 2: # if analysis_assim and hawaii - return "forcing_analysis_assim_hawaii" - elif runinput == 5 and geoinput == 3: # if analysis_assim and puerto rico - return "forcing_analysis_assim_puertorico" - elif runinput == 1 and geoinput == 2: # if short range and hawaii - return "forcing_short_range_hawaii" - elif runinput == 1 and geoinput == 3: # if short range and puerto rico - return "forcing_short_range_puertorico" - elif runinput == 5: # if analysis assim - return "forcing_analysis_assim" - elif runinput == 6: # if analysis_assim_extend - return "forcing_analysis_assim_extend" - elif runinput == 2: # if medium_range - return "forcing_medium_range" - elif runinput == 1: # if short range - return "forcing_short_range" - - elif runinput == 5 and geoinput == 3: # if analysis_assim and puertorico - return "analysis_assim_puertorico" - - elif runinput == 10 and geoinput == 3: # if analysis_assim_no_da and puertorico - return "analysis_assim_puertorico_no_da" - - elif runinput == 1 and geoinput == 3: # if short_range and puerto rico - return "short_range_puertorico" - - elif runinput == 11 and geoinput == 3: # if short_range_no_da and puerto rico - return "short_range_puertorico_no_da" - - else: - return default - - -def fhprefix(runinput): - if 4 <= runinput <= 10: - return "tm" - return "f" - - -def varsuffix(meminput): - if meminput in range(1, 8): - return f"_{meminput}" - else: - return "" - - -def run_typesuffix(meminput): - if meminput in range(1, 8): - return f"_mem{meminput}" - else: - return "" - - -def select_forecast_cycle(fcst_cycle=None, default=None): - if fcst_cycle: - return fcst_cycle - else: - return default - - -def select_lead_time(lead_time=None, default=None): - if lead_time: - return lead_time - else: - return default - - -urlbasedict = { - 0: "", - 1: "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/prod/", - 2: "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/", - 3: "https://storage.googleapis.com/national-water-model/", - 4: "https://storage.cloud.google.com/national-water-model/", - 5: "gs://national-water-model/", - 6: "gcs://national-water-model/", - 7: "https://noaa-nwm-pds.s3.amazonaws.com/", - 8: "s3://noaa-nwm-pds/", - 9: "https://ciroh-nwm-zarr-copy.s3.amazonaws.com/national-water-model/", -} - - -def selecturlbase(urlbasedict, urlbaseinput, defaulturlbase=""): - if urlbaseinput: - return urlbasedict[urlbaseinput] - else: - return defaulturlbase - - -def create_file_list( - runinput, - varinput, - geoinput, - meminput, - start_date=None, - end_date=None, - fcst_cycle=None, - urlbaseinput=None, - lead_time=None, # TODO: change this order; placed here to avoid breaking change -): - """for given date, run, var, fcst_cycle, and geography, print file names for the valid time (the range of fcst_hours) and dates""" - - runsuff = "" - - try: - geography = selectgeo(geodict, geoinput) - except: - geography = "geography_error" - try: - run_name = selectrun(rundict, runinput) - except: - run_name = "run_error" - try: - var_name = selectvar(vardict, varinput) - except: - var_name = "variable_error" - try: - urlbase_prefix = selecturlbase(urlbasedict, urlbaseinput) - except: - urlbase_prefix = "urlbase_error" - - try: - _dtstart = datetime.strptime(start_date, "%Y%m%d%H%M") - _until = datetime.strptime(end_date, "%Y%m%d%H%M") - except: - today = datetime.now(timezone.utc) - _dtstart = today - _until = today - - dates = rrule.rrule( - rrule.DAILY, - dtstart=_dtstart, - until=_until, - ) - run_t = run_type(runinput, varinput, geoinput, run_name) - fhp = fhprefix(runinput) - vsuff = varsuffix(meminput) - rtsuff = run_typesuffix(meminput) - - if runinput == 1: # if short_range - if varinput == 5: # if forcing - if geoinput == 2: # hawaii - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(0, 13, 12)), - select_lead_time(lead_time, range(1, 49)), - ) - elif geoinput == 3: # puertorico - prod = product( - dates, - select_forecast_cycle(fcst_cycle, [6]), - select_lead_time(lead_time, range(1, 48)), - ) - else: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(24)), - select_lead_time(lead_time, range(1, 19)), - ) - elif geoinput == 3: # if puerto rico - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(6, 19, 12)), - select_lead_time(lead_time, range(1, 48)), - ) - else: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(24)), - select_lead_time(lead_time, range(1, 19)), - ) - elif runinput == 2: # if medium_range - if varinput == 5: # if forcing - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(0, 19, 6)), - select_lead_time(lead_time, range(1, 241)), - ) - else: - default_fc = range(0, 19, 6) - if meminput == 1: - if varinput in {1, 3}: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, default_fc), - select_lead_time(lead_time, range(1, 241)), - ) - elif varinput in {2, 4}: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, default_fc), - select_lead_time(lead_time, range(3, 241, 3)), - ) - else: - raise ValueError("varinput") - elif meminput in range(2, 8): - if varinput in {1, 3}: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, default_fc), - select_lead_time(lead_time, range(1, 205)), - ) - elif varinput in {2, 4}: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, default_fc), - select_lead_time(lead_time, range(3, 205, 3)), - ) - else: - raise ValueError("varinput") - else: - raise ValueError("meminput") - elif runinput == 3: # if medium_range_no_da - if varinput == 1: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(0, 13, 6)), - select_lead_time(lead_time, range(3, 240, 3)), - ) - else: - raise ValueError("only valid variable for a _no_da type run is channel_rt") - elif runinput == 4: # if long_range - default_fc = range(0, 19, 6) - if varinput in {1, 3}: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, default_fc), - select_lead_time(lead_time, range(6, 721, 6)), - ) - elif varinput == 2: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, default_fc), - select_lead_time(lead_time, range(24, 721, 24)), - ) - else: - raise ValueError("varinput") - elif runinput == 5: # if analysis_assim (simplest form) - if varinput == 5: # if forcing - if geoinput == 2: # hawaii - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(19)), - select_lead_time(lead_time, range(3)), - ) - else: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(20)), - select_lead_time(lead_time, range(3)), - ) - else: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(24)), - select_lead_time(lead_time, range(3)), - ) - elif runinput == 6: # if analysis_assim_extend - prod = product( - dates, - select_forecast_cycle(fcst_cycle, [16]), - select_lead_time(lead_time, range(28)), - ) - elif runinput == 7: # if analysis_assim_extend_no_da - if varinput == 1: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, [16]), - select_lead_time(lead_time, range(28)), - ) - else: - raise ValueError("only valid variable for a _no_da type run is channel_rt") - elif runinput == 8: # if analysis_assim_long - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(0, 24, 6)), - select_lead_time(lead_time, range(12)), - ) - elif runinput == 9: # if analysis_assim_long_no_da - if varinput == 1: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(0, 24, 6)), - select_lead_time(lead_time, range(12)), - ) - else: - raise ValueError("only valid variable for a _no_da type run is channel_rt") - - elif runinput == 10: # if analysis_assim_no_da - if varinput == 1: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(21)), - select_lead_time(lead_time, range(3)), - ) - else: - raise ValueError("only valid variable for a _no_da type run is channel_rt") - - elif runinput == 11 and geoinput == 3: # if short_range_puertorico_no_da - if varinput == 1: - prod = product( - dates, - select_forecast_cycle(fcst_cycle, range(6, 19, 12)), - select_lead_time(lead_time, range(1, 49)), - ) - else: - raise ValueError("only valid variable for a _no_da type run is channel_rt") - else: - raise ValueError("run error") - - r = [] - for _dt, _fc, _fh in prod: - r.append( - makename( - _dt, - run_name, - var_name, - _fc, - _fh, - geography, - run_t, - fhp, - runsuff, - vsuff, - rtsuff, - urlbase_prefix, - ) - ) - return r - - -def generate_urls( - start_date, - end_date, - fcst_cycle, - lead_time, - varinput, - geoinput, - runinput, - urlbaseinput, - meminput, -): - - start_date = start_date - end_date = end_date - fcst_cycle = fcst_cycle - # fcst_cycle = None # Retrieves a full day for each day within the range given. - # lead_time = [1] - lead_time = lead_time - varinput = varinput - # vardict = {1: "channel_rt", 2: "land", 3: "reservoir", 4: "terrain_rt", 5: "forcing"} - geoinput = geoinput - # geodict = {1: "conus", 2: "hawaii", 3: "puertorico"} - meminput = meminput - urlbaseinput = urlbaseinput - runinput = runinput - - if ( - runinput == 1 - or runinput == 5 - or runinput == 6 - or runinput == 7 - or runinput == 8 - or runinput == 9 - or runinput == 10 - or runinput == 11 - ): - meminput = 0 - print( - "no unsumble members available for the given runinput therefore, meminput set to 0" - ) - # rundict = { - # 1: "short_range", - # 2: "medium_range", - # 3: "medium_range_no_da", - # 4: "long_range", - # 5: "analysis_assim", - # 6: "analysis_assim_extend", - # 7: "analysis_assim_extend_no_da", - # 8: "analysis_assim_long", - # 9: "analysis_assim_long_no_da", - # 10: "analysis_assim_no_da", - # 11: "short_range_no_da", - # } - - file_list = create_file_list( - runinput, - varinput, - geoinput, - meminput, - start_date, - end_date, - fcst_cycle, - urlbaseinput, - lead_time, - ) - if os.path.exists("filenamelist.txt"): - os.remove("filenamelist.txt") - if urlbaseinput == 9: - with open("filenamelist.txt", "wt") as file: - for item in file_list: - file.write(f"{item}.json\n") - else: - with open("filenamelist.txt", "wt") as file: - for item in file_list: - file.write(f"{item}\n") - - -# start_date = "202201120000" -# end_date = "202201130000" -# fcst_cycle = [0,8] -# lead_time = [1,18] -# varinput = 1 -# geoinput = 1 -# runinput = 1 -# urlbaseinput = 2 -# meminput = 1 -# generate_urls(start_date, end_date, fcst_cycle, lead_time, varinput, geoinput, runinput, urlbaseinput, meminput)