Vernal (Spring) Equinox 2021

Upload

It's springtime in the northern hemisphere or autumn if you happen to live south of the equator. Rendered in Catfood Earth.

(Previously: Vernal (Spring) Equinox 2020)

Catfood Earth 4.10

Catfood Earth 4.10

Catfood Earth 4.10 is available for download.

The National Weather Service updated their weather radar API. The weather radar layer has changed a bit, you can enter one or more (comma separated) weather station IDs and Earth will show one hour precipitation for all of them. You used to be limited to a single station but with more options for the rader layer to display. Let me know if you love or hate the new version.

4.10 also includes the latest 2021a time zone database.

(I'm sure there are great reasons for it, but the 'new' NWS API is an XML document per station that links to a HTML folder listing of images where you can enjoy parsing out the latest only to download a TINY GZIPPED TIFF file FFS).

Photo Sorter 1.10

Photo Sorter 1.10

Photo sorter has been updated to skip metadata when comparing JPEG files.

I've been picking up some duplicates when I have both a local copy and a version downloaded from Google Photos. Google Photos knocks out some metadata and so the files look different even though the photo is the same. If you've used Photo Sorter before you'll need to run it over everything again to knock out any copies.

For full details and instructions see the Photo Sorter 1.00 post. You can grab the source or a binary from photo-sorter on github.

Style Transfer for Time Lapse Photography

Style Transfer for Time Lapse Photography

TensorFlow Hub has a great sample for transferring the style of one image to another. You might have seen Munch's The Scream applied to a turtle, or Hokusai's The Great Wave off Kanagawa to the Golden Gate Bridge. It's fun to play with and I wondered how it would work for a timelapse video. I just posted my first attempt, four different shots of San Francisco and I think it turned out pretty well.

The four sequences were all shot on an A7C, one second exposure, ND3 filter and aperture/ISO as needed to hit one thousandth of a second before fitting the filter. Here's an example shot:

Style Transfer for Time Lapse Photography

I didn't want The Scream or The Wave, so I asked my kids to pick two random pieces of art each so I could have a different style for each sequence:

Style Transfer for Time Lapse Photography

The style transfer network wants a 256x256 style image so I cropped and resized the art as needed.

The sample code pulls images from URLs. I modified it to connect to Google Drive, iterate through a source folder of images and write the transformed images to a different folder. I'm running this in Google Colab which has the advantage that you get to use Google's GPUs and the disadvantage that it will disconnect, timeout, run out of memory etc. To work around this the modified code can be run as many times as needed to get through all the files and will only process input images that don't already exist in the output folder. Here's a gist of my adapted colab notebook:

One final problem is that the style transfer example produces square output images. I just set the output to 1920x1920 and then cropped a HD frame out the middle of each image to get around this.

Here's a more detailed workflow for the project:

I usually shoot timelapse with a neutral density filter to get some nice motion blur. When I shot this sequence it was the first time I'd used my filter on a new camera/lens and screwing in the filter threw off the focus enough to ruin the shots. Lesson learned - on this camera I need to nail the focus after attaching the filter. As I've been meaning to try style transfer for timelapse I decided to use this slightly bad sequence as the input. Generally for timelapse I shoot manual / manual focus, fairly wide aperture and ISO 100 unless I need to bump this up a bit to get to a 1 second exposure with the filter.

After shooting I use LRTimelapse and Lightroom 6 to edit the RAW photos. LRTimelapse reduces flicker and works well for applying a pan and/or zoom during processing as well. For this project I edited before applying the style transfer. The style transfer network preserves detail very well and then goes crazy in areas like the sky. Rather than zooming into those artifacts I wanted to keep them constant which I think gives a greater sense of depth as you zoom in or out.

Once the sequence is exported from Lightroom I cancel out of the LRTimelapse render window and switch to Google Colab. Copy the rendered sequence to the input folder and the desired style image and then run the notebook to process. If it misbehaves then Runtime -> Restart and run all is your friend.

To get to video I use ffmpeg to render each sequence. For this project at 24 frames per second and cropping a 1920x1080 frame from each of the 1920x1920 style transfer images.

Then DaVinci Resolve to edit the sequences together. I added a 2 second cross dissolve between each sequence and a small fade at the very beginning and end.

Finally, music. I use Filmstro Pro and for this video I used the track Durian.

Here's the result:

Winter Solstice 2020

Winter Solstice 2020

Winter starts now in the Northern Hemisphere, Summer to the south. 10:03 UTC Dec 21 2020 rendered in Catfood Earth.

(Previously: Winter Solstice 2019)

Autumnal Equinox 2020

Autumnal Equinox 2020

Autumn starts now (September 22, 13:31 UTC) north of the Equator, Spring to the south. Rendered in Catfood Earth.

(Previously: Autumnal Equinox 2019)

Catfood Earth 4.01

Updated on Sunday, April 18, 2021

Catfood Earth 4.01 is available for download.

The timezone database has been updated to 2020a. There is also a small fix to a problem with screensaver installation on recent versions of Windows 10.

Summer Solstice 2020

Summer Solstice 2020

In 2020 the Summer Solstice is at 9:44pm UTC on June 20.

We get solstice from the Latin sol (sun) and sistere (to cause to stand) - the moment when the Sun stands still in its journey from north to south and back again.

Summer Solstice is the instant when the Sun is at its highest point in the sky, on the longest day of the year for the Northern hemisphere. This happens because the Earth is tilted by a little over 23 degrees (our planet rotates once a day, but relative to our orbit around the Sun the axis of rotation is at an angle). As we orbit the Sun this tilt means that different latitudes experience more or less sunlight over the course of a year. This pattern is most extreme near the poles. In the Arctic Circle the Sun never sets at the height of summer and never rises in the depth of winter. We mark two solstices each year, summer and winter. At the Summer Solstice the Sun is directly over the Tropic of Cancer (a little over 23 degrees north). We also observe two equinoxes, spring and fall (vernal and autumnal), halfway through the cycle when the Sun is directly over the Equator and a day is the same length everywhere.

The video below shows how the pattern of day and night changes over one year. You can see when the poles are completely dark or light, and the moment when the Sun 'stands still' before days start to get longer or shorter again.

Here's another perspective. This video shows a view from San Francisco made from pictures that each show a complete day (each vertical line on the picture was shot at a different time with noon at the center). You can see the length of day changing throughout the year. On less foggy days you can also see the position of sunset moving, especially with the days getting longer towards the end when San Francisco experiences less fog.

Summer Solstice isn't always on June 20th - sometimes it's June 21st or June 22nd. Irritatingly a day on your clock is not the same as a solar day and a calendar year is not the same thing as one trip around the Sun. This is why we have leap years and leap seconds to stay roughly in sync with celestial mechanics.

It's also interesting to note that Summer Solstice isn't when we're closest to the Sun or when temperatures are the highest. The Earth's orbit is elliptical and we're actually furthest away around the Summer Solstice (for now - this changes over time). Our Northern hemisphere summer is driven by sunlight hitting us directly rather than at an angle (seasons are driven by the 23 degree tilt and the position of the orbit more than our distance from the Sun). Temperatures continue to rise after the Summer Solstice mainly because it takes a while to heat up water, and so warmer weather lags the increase in direct sunlight (and vice versa as we head into colder weather after the Winter Solstice).

The exact moment of Summer Solstice pictured at the start of the post and the video of day/night over a year were created using Catfood Earth. Catfood Earth generates wallpaper from NASA Blue and Black Marble images to show the current extent of day and night combined with near real time cloud cover. Catfood Earth is totally free and available for Windows and Android.

(Previously)

4K One Year Global Cloud Timelapse

Hurricane Dorian in Catfood Earth

Six 4K images a day at 24 frames per second (so each second is four days) from April 18, 2019 to April 17, 2020:

I made a version of this video a couple of years ago using xplanet clouds. That was lower resolution and only had one frame per day so it's pretty quick. This version uses the new 4K cloud image I developed for Catfood Earth just over a year ago. I've been patiently saving the image six times a day (well, patiently waiting as a script does this for me). It's pretty amazing to see storms developing and careening around the planet. The still frame at the top of the post shows Dorian hitting Florida back in September.

Using the Azure Monitor REST API from Google Apps Script

Updated on Sunday, March 14, 2021

Average Server Response Time in Azure Metrics

This post describes how to get metrics (in this case average response time) from an Azure App Service into a Google Sheet. I’m doing this so I can go from the sheet to a Data Studio dashboard. I already have a report in Data Studio that pulls from Ads, Analytics and other sources. I’d rather spend hours adding Azure there than be forced to have one more tab open. You might have different reasons. Read on. 

  1. Create a Google Sheet and give it a memorable name. Rename the first sheet to AvgResponseTime and put ‘Date’ in A1 and ‘Average Response Time’ in B1.
  2. Create a script (Script editor from the Tools menu) and give that a good name as well.
  3. In the script editor pick Libraries from the Resources menu. Enter 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF which is the Google OAuth library, pick the latest version and click Save.
  4. Select Project properties from the File menu and make a note of the Script ID.
  5. Log into your Azure Console and then go to https://resources.azure.com/. You are looking for a metricdefinitions node for the resource that you want to monitor. In my case it’s subscriptions / MyName Subscription / resourceGroups / providers / Microsoft.Web / sites / MySite / metricdefintions. Browse through this list to find the id of the metric you’re interested in. For me it’s AverageResponseTime. Finding this was the hardest part. Microsoft’s documentation for resourceUri is literally ‘The identifier of the resource.’ Why even bother Microsoft? Make a note of the id and remove the ‘metricDefinitions/AverageResponseTime’ from the end, because of course the ID isn’t quite right for some reason. Mine looks something like this: /subscriptions/mylongid/resourceGroups/mysomethingResourceGroup/providers/Microsoft.Web/sites/mysiteid
  6. Go back to the Azure Console and open Azure Active Directory. Select App registrations under Manage and create a New registration. Time to come up with another name. You probably want ‘Accounts in this organizational directory only’. The redirect URL is https://script.google.com/macros/d/SCRIPTID/usercallback - replace SCRIPTID with the Script ID you made a note of in step 4.
  7. Click the View API permissions button, then Add a permission and then pick Azure Service Management. I’m using Delegated permissions and the user_impersonation permission. Then click Grant admin consent for Default Directory.
  8. Go to Certificates & secrets (under manage) and create a new client secret. Make a careful note of it.
  9. Go to Authentication (under Manage), check Access tokens under Implicit grant and then click Save at the top of the page.
  10. Go to Overview and make a note of your Application (client) ID and Directory (tennant) ID.
  11. You are getting close! Go to the script editor (from step 2) and paste in the code at the bottom of this post. There are four variables to enter at the top of the script. ClientID and TennantID are from step 10. ClientSecret is from step 8. ResourceID is from step 5. Save the script.
  12. Reload the spreadsheet (back from step 1). You should get an Azure Monitor menu item. Choose Authorize from this menu. Google will ask you to authorize the script, do this for the Google account you’re using. Choose Authorize again, this time a sidebar will appear with a link. Follow the link and authorize against Azure (if you’re logged in this might just go directly to success). If you get authorization errors in the future run this step again. If that does help use Reset Settings and then try again.
  13. You should be ready to get data. Choose Fetch Data from the Azure Monitor menu. If this doesn’t work check through steps 1-12 carefully again!
  14. Last step - automate. Go back to the script editor. Choose Current project’s triggers from the Edit menu. Add a trigger (the small blue button hidden at the bottom right of the screen - not everything needs a floating action button Google!) to run fetchData daily at some reasonable time.
You should now have a daily record of average response time flowing to a Google sheet. This can easily be extended to support other metrics, and other time periods (you could get data by minute and run the script hourly for instance. See the metrics documentation for more ideas. I got this working for an App Service but it should be roughly the same flow for anything that supports metrics, you’ll just need to work on finding the right resourceUri / ID.

More Google Apps Script Projects