Friday, August 27, 2021

Technical Details As Acknowledgements

The gauge on my patio has collected over twelve inches of rain since the last week of June. So this week's extended break from the monsoon was welcome, and it provided an opportunity to document some topics neglected in the previous two posts. Also, suggestions and lessons learned might be helpful for anyone wanting to create their own custom weather maps. The first lesson learned is that the link I provided in the previous post quickly turned bad. Here are replacement links to brief summary descriptions about the GFS, which includes the GDAS. Those summaries are on the NOMADS page, which provides public access to gridded data from a variety of National Weather Service models, as well as links to data from other modeling centers. Separately the National Weather Service provides a Model Analysis and Guidance page, where the gridded data have already been processed into standard weather map images of many varieties. If those standard maps are adequate, it might not be necessary for a user to deal with the gridded data.

My custom journeys through the model data are spread out across the screen of my MacBook in the form of maps generated through the python packages matplotlib and Cartopy. Other python packages are involved, which I'll discuss later. I like to keep track of what I'm installing and why. So my starting point is the Homebrew package manager. The starting point for Homebrew is its installation instruction web page. After Homebrew is installed, installation of a particular piece of software under Homebrew is handled by a Formula. Among the Homebrew formulae I've installed and kept updated for a long time are python itself (the formula includes installation of pip) and ipython. Some python packages require access to a library, which can be installed with Homebrew. A tricky detail is that Cartopy requires an older version of the proj library, which happily Homebrew provides as formula proj@7. A recent discovery for me is the formula eccodes, which installs the ECMWF package for decoding GRIB files. This library is needed for a python package to be discussed later. Independent of its companion python package, eccodes installs a set of command line tools. One of these tools is grib_ls, which comes in handy for figuring out what is actually in the file that was downloaded from the NOMADS site.

I keep the standard python packages (cartopy, pandas, numpy, matplotlib, scipy, etc.) updated manually with pip. There is one more tricky thing with Cartopy. A required package, Shapely, needs to be installed using the pip option --no-binary. For easy reading of GRIB files, the python packages cfgrib (interfaces with the eccodes library) and xarray are needed. I came to cfgrib through xarray, and to xarray through the python package MetPy. While intending to eventually use all of MetPy's computational features, for now I'm especially taking advantage of its addition to the map features available in Cartopy (i.e., from metpy.plots import USCOUNTIES).

Here's the easy reading part, illustrated by a line from my python script:
ds = xr.open_dataset(myFilename, engine="cfgrib", filter_by_keys={'typeOfLevel': levelType[levelTypeIndex], 'level':level})
where xarray was imported as xr, and myFilename was set to one of the files I downloaded from NOMADS. The optional argument filter_by_keys gets passed to cfgrib. This filtering is generally necessary, and will be discusssed later.

Jumping to the end of the process for now, assume that a downloaded GRIB file, or at least a subset of it, has been successfully ingested by xarray. Then it's only a matter of adapting from the many MetPy examples available. My personal preference for just viewing the fields is to rely on two matplotlib functions: pcolormesh for the scalars and streamplot for the wind components. For some reason pcolormesh understands the lon/lat/variable inputs when they are supplied as xarray DataArray structures, but streamplot requires extracting the .values property in order to supply ordinary numpy arrays.

So let's back up in the process to discuss downloading. As mentioned near the beginning of this post, the NOMADS page provides access to a wide variety of model gridded fields. I've been routinely looking at the GDAS analysis and the GFS forecast fields on their 0.25 degree grid. Those are just 2 of the nearly 100 datasets listed on the NOMADS page. Most of the datasets are equipped with the grib filter option. Clicking on the link in the previous sentence takes you to the NOMADS page of general instructions. As the instruction page explains, grib filter is best used for creating regional subsets. Following the instructions and finally reaching the "Extract" page, I initially skip past the Extract Levels and Variables section, and so that I don't forget about it scroll down to the Extract Subregion section. It's not enough to just fill in the top/bottom/left/right lat/lon. Also be sure to check the box after the words "make subregion." Returning to the select variables section, if I want just the variables corresponding to standard radiosonde observations I'll select the abbreviated names HGT, TMP, RH, UGRD and VGRD. Depending on the dataset you chose, there might be many more variables. You may need to view Parameter Table Version 2 to figure out the abbreviations. For the levels desired it might be safest to just select "all". Instead I select each level that I want. Some of the level options are actually levelTypes, as can be verified later by running grib_ls on the downloaded file. The variable PWAT needs the level (levelType) "entire atmosphere (considered as a single layer)," while REFC needs "entire atmosphere."

Here is the promised later discussion about the filtering that is generally necessary in connection with xarray's opening of a grib file to create a dataset. For an explanation of why filtering is needed, see in this early documentation for CFGRIB the section Devil In The Details. Basically each message (i.e., each 2_D grid) in a file downloaded from one of the NOMADS "Extract" pages will be a unique combination of the three keys typeOfLevel/level/parameter. But xarray tries to merge all the levels and all the parameters in the file into a level/parameter array. In order to keep xarray happy, it's often enough to restrict xarray's attention to one typeOfLevel. But it may be necessary to also restrict attention to one level, as in my line of code above. An example is when TMP and RH are at level 2 m above ground but UGRD and VGRD are at level 10 m. Xarray with cfgrib's help tries to create a table with 2 levels and 4 parameters, but is disappointed to find that half of the table's entries would be empty. Working out what is in the GRIB file and thus what filtering is needed is where the command line tool grib_ls comes in handy.

Once into a routine of what I want to download, I follow the suggestion at the bottom of the grib filter instruction page, the section "Scripting file retrievals." However instead of a script I just enter the commands interactively in the terminal window. At first I was always copying from my text editor (BBEdit) and pasting to the terminal window, with the first paste being the mutiple lines where I change to my local directory and set the date and time parameters, and the second paste being the curl line. But then I learned to just use the terminal window: ctrl-r to search the history file for text in the last use of the multi-line command, move with arrow keys and make minor edits, ctrl-o to execute that multi-line and bring up the next history line, which is the curl line ready to substitute the new ${hr} ${fhr} and ${date}. Hit return. It takes a little over 5 seconds to do the typing, and another 5 seconds for my 12 by 12 degree lat/lon regional subset 630 Kbyte file of 182 grib messages to download.

Monday, August 9, 2021

Mesoscale Analysis

Forty-some years ago analyzing an upper-air feature like this would have been more about art than data. Fortunately the experienced NCO forecasters who I worked with back then were incredibly perceptive artists. The main source of good data at that time was the FPS-77 radar at Davis-Monthan. The scant information on the upper air charts had to be finely analyzed to make sense of the situation. Now we have the Global Data Assimilation System, output available at a horizontal resolution of 0.25 degree (pixels roughly 25 km on a side), vertical resolution 50 mb or better, every six hours. Tucson is roughly near the center of the images below. The five 500-mbar images span the 24-hour period between midday yesterday and midday today. I haven't yet figured out how to make a loop. But anyway I think the evolution of this wave is best enjoyed one frame at a time.

A wind speed max at midday yesterday over extreme western Chihuahua was by early this morning anchoring the eastern side of a distinct trough, which was centered on an axis extending southwest-northeast through Arizona's Santa Cruz and Cochise Counties. Moderate precipitation was roughly aligned with the wind speed maxes, wrapped around the trough. Probably the evolution of the precipitation, and maybe of the trough itself, was tied to the availability of moisture. The images below show the precipitable water for midday yesterday and midday today. What was striking already yesterday was how the highest values of precipitable water, pegged out on the color bar at >1.7 inches, had pressed into the foothills of the mountains in east-central Sonora. Of significance for the coming days is that southwest New Mexico and northern Chihauhua have moistened since yesterday, even as central Chihuahua has dried.

Friday, June 11, 2021

Interesting Time

While attention in Tucson is on record high temperatures over the next several days, and an eventual increase in moisture, the screaming message from analyses and model forecasts is that there will be a weak or nonexistent mid-level capping inversion by the time the moisture arrives. The 500 mbar temperature this afternoon was -5 deg C. It will probably creep up to -3 C or so at times over the next two or three days. But by Tuesday afternoon the GFS run from 18Z has 500 mbar temperatures around -8 C in a pocket around Tucson. There is also at the same time a bit of an easterly wave racing along the southern extremity of the 500-mbar high. I like to loop the model soundings for Tucson at the NCEP models site. The GFS would have a SW-NE oriented line of storms moving through the Tucson region Tuesday mid afternoon, with measurable rain to the southwest, and significant cooling in Tucson by 5 pm. Things may not work out that way, but it is one of many interesting possibilities.

Sunday, March 21, 2021

Winter 2020-2021 Tucson Rain

Winter 2020-2021 Tucson Rain

A few days ago in an Associated Press story about the Climate Prediction Center's Drought Outlook for the Spring season, the story's lede was that the official forecast offers little hope for relief in the West. The story goes on to explain that the drought in the Southwest has developed from a combination of La Niña dry weather [this winter] coming after, in the words of the source NOAA press release, the failed 2020 summer monsoon.

As far as Tucson is concerned, April through June never offers hope for drought relief. These upcoming months are normally the driest three-month period of the year in Tucson, averaging less than three-quarters of an inch of rain total for the three months combined. The official seasonal outlook puts Tucson in equal chances for below normal, near normal or above normal precipitation for this April through June.

There are still a couple of slight chances for measurable precipitation over the remaining ten days of this month. But they won't make much difference for this November through March period, where the Tucson airport has had 1.42 inches, about 2 inches below average. It could have been worse, considering that it was a moderate La Niña (ONI -1.1 for January 2021). This was the worst winter for precipitation in Tucson since 2010-2011, which was also a moderate La Niña.

At my place I've done a bit better than the airport, 2.59 inches for November through March, but still a big drop off from the previous two winters. The summers following big winters may be just coincidences, but if last summer's monsoon deserved an F grade, the previous summer (2019, at least until after Labor Day) was a D. There's no reason to think that this coming summer won't be at least near normal, at least a B or a C, offering a little hope, though still three months away--this summer's monsoon can't be any worse than last summer.

Monday, October 12, 2020

Analyze The Cap

Tucson's weather this winter will be exceptionally boring—one beautiful sunny day after another—thanks to a La Niña that is as certain as a Joe Biden win, according to outlooks from the Climate Prediction Center and The Economist online. Hopefully we'll get a few inches of rain this winter, not too far below normal. But that likelihood will be only half of what Tucson received in each of the last two winters.

So I'll be spending this winter revisiting the few exciting monsoon days from this past summer, and preparing and hoping for more of those days next summer. My most recent previous post here was on July 8. Three days later on Saturday, July 11, the monsoon made a dramatic appearance around sunset. A line of thunderstorms moved from east to west and resulted in several reports of high winds and damage in the Tucson area, including a 60 mph wind gust at Davis-Monthan Air Force Base. But the days immediately before and after July 11 had a similar weather pattern, and those days were just hot.

The selection of a "forecast problem of the day" as practiced by the National Weather Service amounts to wearing blinders. Typically the problem stated in a NWS discussion is confined to one element, for example "will the high temperature be a degree above or below the record" or "will there be damaging thunderstorm winds?" My gripe is not just that wearing blinders is a poor practice for a forecaster analyzing and monitoring the weather situation, it's that the fixation on a single element carries over to the public forecast, a communications disservice. The problem selected for attention on most summer days should be the underlying feature affecting multiple elements, "what is/will be happening with the cap?"

The cap of concern in the Southwest summer sits around 400-500 mb, as noted in the previous post here, or in terms of dry isentropic levels around 326-336 K. It persists most of the summer, yet can vary—in thickness and/or in height—from day to day and even hour to hour, and the variation can be on small as well as large horizontal scales. Let that stable layer subside several hundred meters, with mixed layer moisture overshooting into dry air at the base of the cap, and suddenly there is space for a record high temperature. Conversely lift that layer several hundred meters, and suddenly thunderstorms. Over the next several months I'll be examining available products that might help with what should be the mantra, "Analyze the cap."

Wednesday, July 8, 2020

Wrong Drumbeat

The Tucson National Weather Service is yet again fascinated and fixated on forecasting days ahead of time record-breaking highs, confidently predicting that Sunday's high will be not just 4 degrees warmer than today's (Wednesday's) 107, but precisely 7 degrees warmer. Dismissed is the more important point that unlike the last several afternoons, which have been just hot, the next several afternoons will be both hot and humid.

I have become fascinated with the "Forecast Soundings" option on the National Weather Service Model Analyses and Guidance page. It's fascinating to watch—not just every 12 hours, but every 3 hours—Tucson's capping inversion at around 400-500 mb evolve diurnally, and from day to day. That inversion rules out nearby thunderstorms today. But the mid-level inhibition becomes much weaker possibly as early as tomorrow afternoon, more consistently by Friday afternoon, along with a flow that would steer isolated, high-based, borderline thunderstorms from the east or southeast. The odds of measurable precipitation reaching the ground any of the next several days are low. But the record or near record hot environment will enhance negative bouyancy of any downdraft. Maybe by the end of the weekend the surface parameter that will have been observed to break a record will not be temperature.

Sunday, June 14, 2020

The continued inanity of June 15th

Nine years ago I railed, twice in the same month, about the silly season of talk about the monsoon. In the second of those June 2011 posts I wrote (misspelling site for sight):

Suppose that someone had lived in Tucson for a couple of decades, then fell into a Rip van Winkle sleep for another couple of decades, and finally awoke last week. Rip van Winkle would be bewildered to hear that the monsoon starts Wednesday, and that, alas, despite the approaching start date there's no rain in site (as if rain in site would be normal for this date in June). As terrible as the wildfires have been this year, and as good as it would be to get enough rain to relieve the situation, that's not a realistic hope this early.

The difference this year is that June 15th arrives on Monday, not Wednesday as it did in 2011. It's still silly to talk about the monsoon starting on June 15th, despite a decade of the National Weather Service pretending otherwise.

At this point it might be enough to say, "See previous posts." But following after this April's remininiscing post, this post goes back forty-some years to the weather station at Davis-Monthan Air Force Base here in Tucson. Since the stations's weather radar and human eyes both had a relatively clear line of sight to the south, at this time of year it would not be uncommon for the weather observer to include in a late afternoon or early evening hourly weather observation an uncannilly precise remark that a thunderstorm cloud was being visibly observed 95 miles to the south. So there was no ignorance about moisture pooling in Mexico. But when a trough in the westerlies would briefly pull some of that moisture north and generate a thunderstorm or two, customers would be briefed that, "That was not the monsoon." Emphasis was on the long-term correlation between the north-to-south transition from dry to moist air and the north-to-south transition from westerly to easterly upper-level winds. Thunderstorms, at least scattered coverage, moving generally from east to west, day after day (or at least most days)--like pornography, Tucsonans know what they expect from the monsoon. And until recent decades forecasters understood how to tailor and communicate their monsoon call for locals.

I have no qualms about a firefighter labeling the entire difficult month of June as a nebulous and agonizingly long period known as "at the start of the monsoon." But I doubt a firefighter would insist that the lightning strike on the evening of June 5, which sparked the Bighorn Fire, was "not the monsoon" while at the same time insisting that a lightning strike tomorrow evening would be "the monsoon." That would be just silly.