Life, Technology, and Meteorology

Month: February 2008

CFNetwork Versions

Sometimes it’s important to know what version of Mac OS X your users are running, especially when making decisions on what versions of OS X to support in future software releases. In the case of Seasonality 2.0, I have decided to take advantage of all the developer changes in Leopard, both to make Seasonality a better application, and to shorten my development time (thus giving me more time to work on additional features).

Previously, I haven’t performed any OS statistics on user data. It would be easy to do, since Seasonality downloads forecast and image data from a web server here at Gaucho Software, but I haven’t written the code required. However, some of these Seasonality data requests are using the typical CFNetwork methods of downloading data, and these connections provide the current CFNetwork version in the HTTP UserAgent, and thus will show up in my web server logs.

The problem is that I have been unable to find any kind mapping between CFNetwork versions and the corresponding version of Mac OS X. I decided to take it upon myself to generate (and hopefully maintain) such a list here. Most of this data is from viewing the Darwin source code on Apple’s web site, but some of these are just from personal observations, and some are educated guesses (marked with a question mark).

HTTP UserAgent   Version of Mac OS X
CFNetwork/454.4   Mac OS X 10.6.0
CFNetwork/438.14   Mac OS X 10.5.8
CFNetwork/438.12   Mac OS X 10.5.7
CFNetwork/422.11   Mac OS X 10.5.6
CFNetwork/339.5   Mac OS X 10.5.5
CFNetwork/330.4   Mac OS X 10.5.4
CFNetwork/330   Mac OS X 10.5.3
CFNetwork/221.5   Mac OS X 10.5.2
CFNetwork/221.2   Mac OS X 10.5.2 Developer Seed?
CFNetwork/220   Mac OS X 10.5.1?
CFNetwork/217   Mac OS X 10.5?
 
CFNetwork/129.22   Mac OS X 10.4.11
CFNetwork/129.20   Mac OS X 10.4.9 – 10.4.10
CFNetwork/129.18   Mac OS X 10.4.8
CFNetwork/129.16   Mac OS X 10.4.7
CFNetwork/129.13   Mac OS X 10.4.6
CFNetwork/129.10   Mac OS X 10.4.4 – 10.4.5 (Intel)
CFNetwork/129.9   Mac OS X 10.4.4 – 10.4.5 (PPC)
CFNetwork/129.5   Mac OS X 10.4.3
CFNetwork/128.2   Mac OS X 10.4.2
CFNetwork/128   Mac OS X 10.4.0 – 10.4.1
 
CFNetwork/4.0   Mac OS X 10.3 or earlier

Edit: A more modern list of UserAgents can be found here.

GRIB2 Migration

A few days ago I started having a problem with the previous GFS forecast data source I was using for Seasonality forecasts. Just as a bit of background, Seasonality will download forecasts for U.S. locations from the NWS’s NDFD service. For locations outside the U.S., I have to get the data from somewhere else, and the best data source I’ve been able to find is 0.5 degree GFS model output, also available from the NWS. Because the GFS model data is in GRIB format and very large, I first download it to a “forecast” server that I host, and throw it all into a database. Then Seasonality will contact my forecast server to get the forecast for its configured locations.

With the old GFS data source offline, I had to find a new one. I came across a production server at NCEP that hosted 0.5 degree GFS model output, but the data was in GRIB2 format, which presented a problem because up until this point, all of my forecast data was in GRIB (or GRIB1) format.

Fortunately, there were very few modifications because of the format change, but there are some adjustments that needed to be made. I am using the wgrib and wgrib2 tools to convert the GRIB data to ASCII format first, so it’s easier to parse when importing it into the database. With wgrib, I would use a command like this to convert the data to ASCII:

wgrib -s <grib_file> | egrep \":<variable>:<level>\" | wgrib -i -grib <grib_file> -text -o <txt_file>

The authors of wgrib2 changed things a bit, and actually made the command a little bit easier:

wgrib2 -s <grib_file> | egrep \":<variable>:<level>\" | wgrib2 -i <grib_file> -text <txt_file>

The first two commands in the string don’t change at all, but the third one does. The -grib and -o flags are no longer needed. wgrib2 assumes that the input file is in GRIB2 format, and if you specify -text, the next argument is assumed to be the output file. The problem was that my output data wasn’t right. For some reason, my forecasts were just all screwed up, even though the ASCII files themselves looked okay. I ended up finding some documentation on the -text flag, and it seems that the default output order has been changed from the original North->South to South->North, so all of my data was being inverted. This was somewhat problematic, since I don’t really want to return a forecast for the southern hemisphere when someone asks for a location in the northern hemisphere. The fix is fairly simple, just pass -order raw to the wgrib2 command…

wgrib2 -s <grib_file> | egrep \":<variable>:<level>\" | wgrib2 -i <grib_file> -order raw -text <txt_file>

In general, it looks like most of the NWS datasets will only be available in GRIB2 in the near future, so I hope this information saves other wgrib users some time when doing their own GRIB -> GRIB2 migrations.

© 2026 *Coder Blog

Theme by Anders NorenUp ↑