# Cge tutorial - uv index

CGE Timepieces UV Index Tutorial

Summary
Dear fellow creators,
Facer currently has no tag for UV index. I created a long expression that will produce a number from 1 to 11 based on many individual factors. When I first started trying to figure out how to accomplish this task, I quickly realized that there are many ways to go about this. I feel that I have come up with a logical working index. You could certainly make changes to my expressions to suit your idea of what and/or how things should be factored in. My index seems to report on the higher side at times, but Iâ€™d prefer that to reporting too low. The following is my Total UV index, but I encourage you to read this entire tutorial before using it. You also must read on to find the opacity expression because you will need a second layer with text set at 0.

`((\$(#DH#+#Dm#/60)>=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))-2)&&(#DH#+#Dm#/60)<=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))+2)?1:0\$)+(\$(#DH#+#Dm#/60)>=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))-4)&&(#DH#+#Dm#/60)<=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))+4)?1:0\$)+(\$#WCCI#=01||#WCCI#=02?1:0\$)+(\$#DH#=(round(((#WSH#-#WRH#)/2)+#WRH#))&&#WCCI#=01?2:0\$)+(\$#DH#=(round(((#WSH#-#WRH#)/2)+#WRH#))&&#WCCI#=02?2:0\$)+(\$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))-1)&&#WCCI#=01?2:0\$)+(\$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))-1)&&#WCCI#=02?2:0\$)+(\$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))+1)&&#WCCI#=01?2:0\$)+(\$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))+1)&&#WCCI#=02?2:0\$)+(\$#LAT#<20&&#LAT#>-20?3:0\$)+(\$#LAT#>=20&&#LAT#<=45?1:0\$)+(\$#LAT#>=-45&&#LAT#<=-20?1:0\$)+(\$#LAT#>20&&#DD#>=174&&#DD#<=265?2:0\$)+(\$#LAT#<-20&&#DD#>=355||#DD#<=78?2:0\$)+(\$#LAT#>20&&#DD#>=79&&#DD#<=173?1:0\$)+(\$#LAT#<-20&&#DD#>=266&&#DD#<=354?1:0\$)+(\$#ALT#>5000?1:0\$)+(\$#LAT#<0?1:0\$))`

The UV (ultraviolet) index is a measurement of the sunâ€™s ultraviolet damaging rays based on many variables. The standard index normally ranges between 0 and 11, but can sometimes be a bit higher. UV radiation is a known cause of skin cancer.

Factors
Factors that contribute to the dayâ€™s UV index are the time of day, amount of sun/cloud cover, the season, your latitudinal position on the globe, your altitude, ozone layer density, earthâ€™s reflective surface, and land cover (trees, buildings and other shading). It is very important to understand how all of these factors affect the amount of UV radiation you receive at a given time and place.
Obviously there is no good way to factor in reflective surfaces such as water or snow as well as land cover shade.
I am not a radiation scientist or meteorologist. I came up with this UV index based on my common sense using the #tags# available to me at this time. My UV index is basically a total sum of individual expressions that I created, each one giving a certain â€śweightingâ€ť or value to each of the factors. For each factor, a number, or what I will call a â€śpointâ€ť is given. It may seem like Iâ€™m being redundant when it comes to time of day and cloud cover but there are reasons. For example, I did not want to give 3 points for sun and have that added in early in the day, just as I did not want to have 3 points around solar noon when it is total overcast conditions. So, I have many individual targeted codes set at 1 or 2 points each instead.

Time of day (day and night) - The time of day is extremely important. When there is no sun, there is no UV radiation. I could not reliably incorporate the condition of night and day into my formula and so chose to add this to the opacity field: `\$((#DH#)+(#Dm#/60))>=(((#WRH#)+(#WRm#/60))+1)&&((#DH#)+(#Dm#/60))<=(((#WSH#)+(#WSm#/60))-1)?100:0\$` The + 1 and -1 in this code represents the amount of time in hours after sunrise and before sunset that you want anything to show above 0. There is miniscule UV radiation as the sun rises and sets. My suggestion would be to keep the 1, or change the numbers to 2. You will need to create another layer (call it UV 0) in the same place as your UV index number and simply change the ending to the opacity code above to â€ś?0:100\$â€ť. When the day is between the sunrise and sunset settings, all of the following expressions will appear.

Time of day (before and after solar noon) - UV radiation is the strongest when the sun is at or within a few hours of the dayâ€™s solar noon position. I chose to use two expressions for this very important factor. The 1st expression will give 1 point when the following condition is met (2 hours before to 2 hours after solar noon): `\$(#DH#+#Dm#/60)>=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))-2)&&(#DH#+#Dm#/60)<=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))+2)?1:0\$` The 2nd expression will give another point across a broader range before and after solar noon, (4 hours): ` \$(#DH#+#Dm#/60)>=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))-4)&&(#DH#+#Dm#/60)<=((((((#WSH#+#WSm#/60)-(#WRH#+#WRm#/60)))/2)+(#WRH#+#WRm#/60))+4)?1:0\$`

Sun/cloud cover - Obviously UV radiation will be stronger when not obstructed by several thick clouds. I give 1 point to the total UV index when the weather is either clear (WCCI 01), or few clouds (WCCI 02). Total overcast or mostly clouds will reduce radiation, but a few clouds, short term, can be the same or higher than full sunny days. This may be because the radiation is refracted and increased as it bounces through wispy like clouds. `\$#WCCI#=01||#WCCI#=02?1:0\$`

Sunny at, or around solar noon - 2 points will be given when it is sunny in combination with proximity to solar noon with 3 expressions as follows: `\$#DH#=(round(((#WSH#-#WRH#)/2)+#WRH#))&&#WCCI#=01?2:0\$ \$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))-1)&&#WCCI#=01?2:0\$ \$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))+1)&&#WCCI#=01?2:0\$`

Few clouds at, or around solar noon - 2 points will be given when there are a few clouds in combination with proximity to solar noon with 3 expressions as follows: `\$#DH#=(round(((#WSH#-#WRH#)/2)+#WRH#))&&#WCCI#=02?2:0\$ \$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))-1)&&#WCCI#=02?2:0\$ \$#DH#=((round(((#WSH#-#WRH#)/2)+#WRH#))+1)&&#WCCI#=02?2:0\$`

Latitudes between 20 degrees N and 20 degrees S - The closer you are to the equator, the closer you are to the sun and therefore will be subject to much more UV radiation. I have given 3 points if your location is within 20 degrees N and 20 degrees S of the equator. ` \$#LAT#<20&&#LAT#>-20?3:0\$`

Latitudes from 20 to 45 degrees N or S of the equator - I have given 1 pt if your location is between 20 degrees and 45 degrees N or S. `\$#LAT#>=20&&#LAT#<=45?1:0\$` `\$#LAT#>=-45&&#LAT#<=-20?1:0\$`

Summer season - Because of the earthâ€™s tilt, during summer you would be exposed to a higher level of UV radiation. I have given 2 points for Summer when your location is greater than 20 degrees N or S of the equator. If you are living near the equator there is little seasonal change and 3 pts were already given prior, so nothing is added for seasons +/-20 degrees. `\$#LAT#>20&&#DD#>=174&&#DD#<=265?2:0\$ \$#LAT#<-20&&#DD#>=355||#DD#<=78?2:0\$`

Spring season - Spring is the next highest season for increased UV rays since the days continue to get longer/closer to Summer as Spring progresses. I have given 1 point for Spring for each hemisphere as follows: `\$#LAT#>20&&#DD#>=79&&#DD#<=173?1:0\$ \$#LAT#<-20&&#DD#>=266&&#DD#<=354?1:0\$`

Altitude - When you are at a higher altitude you are at increased risk of UV exposure because of the decreased level of ozone protection. The #ALT# tag in Facer is buggy and not so accurate but in any case I have given 1 point for elevations above 5000. ` \$#ALT#>5000?1:0\$`

Ozone layer- While difficult to gauge the ozone layer based on your location apart from your elevation, there is one fact - ozone rises from the tropics to the northern hemisphere due to the Brewer-Dobson circulation effect. Countries like Australia have lower ozone levels allowing for more UV radiation. I have given 1 point for all locations south of the equator. ` \$#LAT#<0?1:0\$`

I have incorporated the UV figure into some of my watches already. I hope you found this tutorial enlightening and Iâ€™m happy to supply this new #UV# to allow all of my fellow designers to create the very best watches possible. Please let me know if you have any questions.

Did you like this tutorial? LMK !

It would be cool if you gave me credit in your watch face description when using this within the 1st couple months of publishing date of this tutorial, but itâ€™s not necessary!

7 Likes

Wow . Amazing .

2 Likes

That is pretty cool! You got my brain rotating now â€¦ as in, what else can be calculatedâ€¦

3 Likes

Some one asked me in the early days if a colour mixing thing I did could be a Mood Stone. I was looking to see if I could use the battery temprature as an indication of temprature. No go on an Active. I could do it now. I Know so much more about it now. It would not be a one liner like @thomasfmal s formula.

2 Likes

Brilliant, thank you so very much for sharing this with us all, and for all your time and effort

2 Likes

Jesus!

4 Likes

AWSOME WORK! Thank you for sharing it with us!

2 Likes

UPDATE

The one thing about my work that bothered me was the Spring and Summer expressions for the Northern and Southern hemispheres. As we all know, there can be consequences when trying to use more than 2 conditional statements.
Therefore, I have deleted the Spring and Summer expressions for both the North and South and substituted the following which will give 1pt for the Spring month leading into Summer and 2pts for each of the Summer months. This now uses calendar seasons rather than astronomical seasons as I had prior.

Spring N May -` \$#LAT#>20&&#DM#=5?1:0\$`
Summer N June - `\$#LAT#>20&&#DM#=6?2:0\$`
Summer N July - `\$#LAT#>20&&#DM#=7?2:0\$`
Summer N August - `\$#LAT#>20&&#DM#=8?2:0\$`
Spring S November - `\$#LAT#<-20&&#DM#=11?1:0\$`
Summer S December - `\$#LAT#<-20&&#DM#=12?2:0\$`
Summer S January - `\$#LAT#<-20&&#DM#=1?2:0\$`
Summer S February - `\$#LAT#<-20&&#DM#=2?2:0\$`

Please update if you will be using my UV index expression. Let me know if you have any questions.

3 Likes

This is pretty clever stuff @thomasfmal, nicely done & reasonably worked out. Iâ€™ll have to try it out. I like how your update accomodates seasonal changes too, as I was wondering about that factor as I was reading the first part.

2 Likes