Skip to content

Commit

Permalink
Update katrina notebook to new scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mandli committed May 22, 2020
1 parent 5cf26d1 commit c91828a
Showing 1 changed file with 66 additions and 32 deletions.
98 changes: 66 additions & 32 deletions notebooks/geoclaw/katrina/katrina.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"# -------------\n",
"# Initial time:\n",
"# -------------\n",
"clawdata.t0 = -days2seconds(3)\n",
"clawdata.t0 = -days2seconds(2)\n",
"\n",
"# Restart from checkpoint file of a previous run?\n",
"# If restarting, t0 above should be from original run, and the\n",
Expand All @@ -253,7 +253,7 @@
"\n",
"if clawdata.output_style == 1:\n",
" # Output nout frames at equally spaced times up to tfinal:\n",
" clawdata.tfinal = days2seconds(1)\n",
" clawdata.tfinal = days2seconds(2)\n",
" recurrence = 4\n",
" clawdata.num_output_times = int((clawdata.tfinal - clawdata.t0) *\n",
" recurrence / (60**2 * 24))\n",
Expand Down Expand Up @@ -282,9 +282,9 @@
"metadata": {},
"source": [
"#### Initial Time\n",
"With that we are now ready to set some times in our simulation. First is the time we want the simulation to begin. Given that landfall is set to `t=0` we will want to start a few days before then to see how the hurricane progresses towards shore. In this `setrun.py` we have set this to 3 days before landfall via\n",
"With that we are now ready to set some times in our simulation. First is the time we want the simulation to begin. Given that landfall is set to `t=0` we will want to start a few days before then to see how the hurricane progresses towards shore. In this `setrun.py` we have set this to 2 days before landfall via\n",
"```python\n",
"clawdata.t0 = -days2seconds(3)\n",
"clawdata.t0 = -days2seconds(2)\n",
"```"
]
},
Expand All @@ -295,12 +295,12 @@
"#### Output and Final Time\n",
"There are multiple output styles supported by GeoClaw but the one most often used is `output_style = 1`. This allows us to specify a final time `tfinal` and the number of output we want between the initial time `t0` and `tfinal`. The relevant code here is\n",
"```python\n",
"clawdata.tfinal = days2seconds(1)\n",
"clawdata.tfinal = days2seconds(2)\n",
"recurrence = 4\n",
"clawdata.num_output_times = int((clawdata.tfinal - clawdata.t0) *\n",
" recurrence / (60**2 * 24))\n",
"```\n",
"We have set the final time for the simulation to be 1 day after landfall (again relative to landfall being `t=0`) and have asked for 4 output times per day. Again you can simply specify a number for `num_output_times` but this allows you to specify easily by output per day. For instance if you wanted to do hourly output you would do `recurrence = 24`."
"We have set the final time for the simulation to be 2 days after landfall (again relative to landfall being `t=0`) and have asked for 4 output times per day. Again you can simply specify a number for `num_output_times` but this allows you to specify easily by output per day. For instance if you wanted to do hourly output you would do `recurrence = 24`."
]
},
{
Expand Down Expand Up @@ -331,13 +331,19 @@
"\n",
"Gauges allow for measurement of the values of either `q` or `aux` at place through a chosen time range. To do this you can add gauges by appending to the gauges list via\n",
"```python\n",
"# Grand Isle, LA (Station ID: 8761724)\n",
"gauges.append([1, -89.96, 29.26, rundata.clawdata.t0, rundata.clawdata.tfinal])\n",
"\n",
"rundata.gaugedata.gauges.append([4, -94.13, 29.58,\n",
" rundata.clawdata.t0,\n",
" rundata.clawdata.tfinal])\n",
"# Pilots Station East, SW Pass, LA (Station ID: 8760922)\n",
"gauges.append([2, -89.41, 28.93, rundata.clawdata.t0, rundata.clawdata.tfinal])\n",
"\n",
"# Dauphin Island, AL (Station ID: 8735180)\n",
"gauges.append([3, -88.08, 30.25, rundata.clawdata.t0, rundata.clawdata.tfinal])\n",
"```\n",
"This particular gauge is labeled as gauge \"4\", is located at longitude\\latitude `(-94.13, 29.58)` and will be actively recording for the entire time of the simulation. In addition to this you can specify what fields you would like to output. As it is often useful to know the wind velocity and pressure we can add the line\n",
"These particular gauges are simply enumerated gauges but co-located with actual NOAA gagues and will be actively recording for the entire time of the simulation. In addition to this you can specify what fields you would like to output. As it is often useful to know the wind velocity and pressure we can add the line\n",
"```python\n",
"# Force the gauges to also record the wind and pressure fields\n",
"rundata.gaugedata.aux_out_fields = [4, 5, 6]\n",
"```\n",
"to record fields 4, 5, and 6 which are the x-velocity of wind, the y-velocity of wind and pressure in this particular case (more on determining which aux fields store what later).\n",
"\n",
Expand Down Expand Up @@ -510,22 +516,20 @@
"\n",
"# Convert ATCF data to GeoClaw format\n",
"clawutil.data.get_remote_file(\n",
" \"http:https://ftp.nhc.noaa.gov/atcf/archive/2008/bal092008.dat.gz\")\n",
"atcf_path = os.path.join(scratch_dir, \"bal092008.dat\")\n",
" 'http:https://ftp.nhc.noaa.gov/atcf/archive/2005/bal122005.dat.gz')\n",
"atcf_path = os.path.join(scratch_dir, \"bal122005.dat\")\n",
"# Note that the get_remote_file function does not support gzip files which\n",
"# are not also tar files. The following code handles this\n",
"with gzip.open(\".\".join((atcf_path, 'gz')), 'rb') as atcf_file, \\\n",
" open(atcf_path, 'w') as atcf_unzipped_file:\n",
"with gzip.open(\".\".join((atcf_path, 'gz')), 'rb') as atcf_file, open(atcf_path, 'w') as atcf_unzipped_file:\n",
" atcf_unzipped_file.write(atcf_file.read().decode('ascii'))\n",
"\n",
"# Read in the newly downloaded and decompressed file\n",
"ike = Storm(path=atcf_path, file_format=\"ATCF\")\n",
"katrina = Storm(path=atcf_path, file_format=\"ATCF\")\n",
"\n",
"# Calculate landfall time - Need to specify as the file above does not\n",
"# include this info (9/13/2008 ~ 7 UTC)\n",
"ike.time_offset = datetime.datetime(2008, 9, 13, 7)\n",
"katrina = Storm(path=atcf_path, file_format=\"ATCF\")\n",
"\n",
"ike.write(data.storm_file, file_format='geoclaw')\n",
"katrina.write(data.storm_file, file_format='geoclaw')\n",
"```"
]
},
Expand Down Expand Up @@ -592,7 +596,7 @@
"# Storm parameters - Parameterized storm (Holland 1980)\n",
"data.storm_specification_type = 'holland80' # (type 1)\n",
"data.storm_file = os.path.expandvars(os.path.join(os.getcwd(),\n",
" 'ike.storm'))\n",
" 'katrina.storm'))\n",
"```\n",
"These parameters specify what kind of storm field parameterization to use. In this case we will use the paramterization specified in Holland's 1980 paper. The second parameter tells GeoClaw where to look for the storm data such as the track, intensity, pressure, etc. This file should be formatted in the GeoClaw storm format."
]
Expand All @@ -605,12 +609,11 @@
"```python\n",
"# Convert ATCF data to GeoClaw format\n",
"clawutil.data.get_remote_file(\n",
" \"http:https://ftp.nhc.noaa.gov/atcf/archive/2008/bal092008.dat.gz\")\n",
"atcf_path = os.path.join(scratch_dir, \"bal092008.dat\")\n",
" 'http:https://ftp.nhc.noaa.gov/atcf/archive/2005/bal122005.dat.gz')\n",
"atcf_path = os.path.join(scratch_dir, \"bal122005.dat\")\n",
"# Note that the get_remote_file function does not support gzip files which\n",
"# are not also tar files. The following code handles this\n",
"with gzip.open(\".\".join((atcf_path, 'gz')), 'rb') as atcf_file, \\\n",
" open(atcf_path, 'w') as atcf_unzipped_file:\n",
"with gzip.open(\".\".join((atcf_path, 'gz')), 'rb') as atcf_file, open(atcf_path, 'w') as atcf_unzipped_file:\n",
" atcf_unzipped_file.write(atcf_file.read().decode('ascii'))\n",
"```\n",
"This code fetches the data for the storm we are interested in fetching, which is located at http:https://ftp.nhc.noaa.gov/atcf/archive/2008/bal092008.dat.gz. Note that this is a great place to get data to use for most storms througout the world."
Expand All @@ -623,7 +626,7 @@
"#### Read in the ATCF Storm Data into a Storm Object\n",
"```python\n",
"# Read in the newly downloaded and decompressed file\n",
"ike = Storm(path=atcf_path, file_format=\"ATCF\")\n",
"katrina = Storm(path=atcf_path, file_format=\"ATCF\")\n",
"```\n",
"Next we read in the uncompressed ATCF data and create a storm object."
]
Expand All @@ -634,10 +637,8 @@
"source": [
"#### Set the Landfall Time\n",
"```python\n",
"\n",
"# Calculate landfall time - Need to specify as the file above does not\n",
"# include this info (9/13/2008 ~ 7 UTC)\n",
"ike.time_offset = datetime.datetime(2008, 9, 13, 7)\n",
"# Calculate landfall time\n",
"katrina.time_offset = datetime.datetime(2005, 8, 29, 11, 10)\n",
"```\n",
"Now we set a time offset so that we know relative to the data in the ATCF file what time is `t = 0`. Again this is often set to landfall but in the end this parameter does not matter except to know where we are relative to the original ATCF dates."
]
Expand All @@ -648,7 +649,7 @@
"source": [
"#### Write Out the Storm Object\n",
"```python\n",
"ike.write(data.storm_file, file_format='geoclaw')\n",
"katrina.write(data.storm_file, file_format='geoclaw')\n",
"```\n",
"Finally we write out the new storm data into the GeoClaw storm format. We are now ready to have GeoClaw read it in and use the data."
]
Expand All @@ -674,8 +675,29 @@
"outputs": [],
"source": [
"%%bash\n",
"make .data\n",
"make .output"
"export FFLAGS=\"-O3 -funroll-loops -finline-functions -fopenmp\"\n",
"export OMP_NUM_THREADS=4\n",
"make new"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"make data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"make output"
]
},
{
Expand Down Expand Up @@ -727,6 +749,17 @@
"respectively."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"make plots\n",
"open _plots/_PlotIndex.html"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -746,7 +779,8 @@
"outputs": [],
"source": [
"%%bash\n",
"make .plots"
"make .plots\n",
"open _plots/_PlotIndex.html"
]
}
],
Expand Down

0 comments on commit c91828a

Please sign in to comment.