WXforum.net

Weather Software => Station Software Development => Topic started by: iisfaq on August 03, 2021, 08:24:55 PM

Title: Has anyone seen a forumula for clothing layers based on temperature?
Post by: iisfaq on August 03, 2021, 08:24:55 PM
Hi

Our country wide Met Service shows a clothing layer value for each city. My city is here https://www.metservice.com/towns-cities/locations/christchurch (https://www.metservice.com/towns-cities/locations/christchurch), currently it is 10.2 degrees C and it says 2 layers and 0 wind proof (at my house there is no wind at all).

(https://i.ibb.co/gVFsg81/Layers.png) (https://imgbb.com/)

Earlier morning like 7am it said 3 to 4 layers and at least 1 wind proof layer even though the temperature was about the same. But the sun had not risen and pretty much no wind.

I am wondering how they calculate this? 

They did explain a simple formula about 10 years  (https://blog.metservice.com/FeelsLikeTemp) based on Steadmanís Clothing index (1971) but this would have said 1mm of clothing this morning which is if anything 1 layer this morning so they have updated their formula.

(https://blog.metservice.com/wp-content/uploads/2009/12/clothingindex..jpg)

Has anyone seen a formula for this, I like the idea of displaying this on my own site as I guess others would as well.

Chris
Title: Re: Has anyone seen a forumula for clothing layers based on temperature?
Post by: iisfaq on August 29, 2021, 07:47:26 PM
I got some feedback from our local metservice and I put it into this code.  Note you also need the attached JSON file (you will need to rename from .txt since the forum does not like .json)


Feelslike is in degrees Celsius.
Windspeed in Kilometres per hour.

Code: [Select]
using Newtonsoft.Json;
using System.Collections.Generic;

public partial class ClothingLayers
{
    [JsonProperty("temp")]
    public long Temp { get; set; }

    [JsonProperty("clothing")]
    public List<string> Clothing { get; set; }
}

Code: [Select]
  private static List<ClothingLayers> clothingLayersMatrix;

  public static string GetClothingLayers(double feelsLike, double windSpeed)
    {
        int WindIndex = GetWindClothingIndex(windSpeed);
        if (clothingLayersMatrix == null)
        {
            string Lookup = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/ClothingLayers.json"));
            clothingLayersMatrix = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClothingLayers>>(Lookup);
        }
        return feelsLike < 1 ? "4" : feelsLike > 22 ? "1" : clothingLayersMatrix.Find(temp => temp.Temp == feelsLike).Clothing[WindIndex];
    }

    private static int GetWindClothingIndex(double windSpeedKph)
    {
        int ffKphIndex = 0;

        if (windSpeedKph < 2.5)
        {
            ffKphIndex = 0;
        }
        else if (windSpeedKph >= 2.5 && windSpeedKph < 7.5)
        {
            ffKphIndex = 1;
        }
        else if (windSpeedKph >= 7.5 && windSpeedKph < 12.5)
        {
            ffKphIndex = 2;
        }
        else if (windSpeedKph >= 12.5 && windSpeedKph < 17.5)
        {
            ffKphIndex = 3;
        }
        else if (windSpeedKph >= 17.5 && windSpeedKph < 22.5)
        {
            ffKphIndex = 4;
        }
        else if (windSpeedKph >= 22.5 && windSpeedKph < 27.5)
        {
            ffKphIndex = 5;
        }
        else if (windSpeedKph >= 27.5 && windSpeedKph < 32.5)
        {
            ffKphIndex = 6;
        }
        else if (windSpeedKph >= 32.5 && windSpeedKph < 37.5)
        {
            ffKphIndex = 7;
        }
        else if (windSpeedKph >= 37.5 && windSpeedKph < 42.5)
        {
            ffKphIndex = 8;
        }
        else if (windSpeedKph >= 42.5 && windSpeedKph < 47.5)
        {
            ffKphIndex = 9;
        }
        else if (windSpeedKph >= 47.5 && windSpeedKph < 52.5)
        {
            ffKphIndex = 10;
        }
        else if (windSpeedKph >= 52.5)
        {
            ffKphIndex = 11;
        }
        return ffKphIndex;
    }

Being used on my site

(https://i.ibb.co/Hdv2CZb/Clothing-Layers.png) (https://imgbb.com/)