---
title: "Sunsets ๐"
order: 3
#author:
# - name: "Declan Naughton ๐งฎ๐จโ๐ป"
# url: "https://calcwithdec.dev/about.html"
#description: "Sunsets ๐ over Cave Hill"
format:
html:
echo: false
---
*This is a live simulation of the sunset from Cave Hill in Belfast. If you don't see the sun, it might be because it isn't the afternoon/evening in Belfast. You can use the controls to skip hours, and speed up for multiple sunsets!*
::: {.callout-note title="sunsets model"}
The sunsets calculang model replicates numbers from the awesome [ SunCalc ](https://github.com/mourner/suncalc) by [ Volodymyr Agofonkin ](https://agafonkin.com/) .
:::
<details><summary>coordinates (default=Cave Hill)</summary>
```{ojs}
//viewof point = worldMapCoordinates([-5.9537511, 54.647343]) // cave hill
viewof point = location({value: [-5.9537511, 54.647343], label: "Co-ords"})
```
</details>
```{ojs}
title = d3.timeFormat('%B')(current_time.date)
embed(calcuvizspec({
models: [main],
input_cursors: [{
lat_in:point[1], lng_in:point[0], obj_in:'sun', date_in: new Date(current_time.date)//:date_fns.addSeconds(new Date()
}],
mark: {type:'point',size:2000,filled:true,tooltip:true, clip:clip2},
encodings: {
y: {grid: false,name: 'altitude_obj', type:'quantitative', scale: {zero: false, domain: [0,1]}},
x: {grid:false,name: 'azimuth_obj', type: 'quantitative', scale: {zero: false, domain: [0,2]}},
detail: {name:'date_in', domain: [new Date(current_time.date)]}
/*color: {name: 'date_in', sort:'ascending', type: 'quantitative', legend:true, domain:
d3.timeHour.range(
new Date(d).setHours(clip2 ? 13 : 0),
new Date(d).setHours(clip2? 21 : 24),
1
),}*///_.range(-60,24*60,30).map(d => date_fns.addMinutes(new Date(date_in), d))},
// row: additional months ..?
},
width:500 * (clip ? 1 : 0.5),
height:400 * (clip ? 1 : 0.5),
spec_post_process: s => { /*s.encoding.color.timeUnit = 'hours';*/ s.title = title; s.titleFontSize = 40;
s.encoding.color = {value:'orange'};
/*s.encoding.color.scale = {"scheme": "lightmulti"};*/ return s }
}), {actions:true, config: {view: {fill:'#efefff'}}})
```
<details><summary>controls ๐น๏ธ</summary>
```{ojs}
actions = true
Inputs.bind(timeButtons({frameInterval: 50, step: 20000, speed: 1}), viewof current_time)
md`<br/>*-or-*`
viewof current_time = timeSliders({value: new Date(), width: 600, withUtcSlider: true})
viewof clip = Inputs.toggle({label: "clip", value: true})
viewof clip2 = Inputs.toggle({label: "clip2", value: true})
import { range, dayOfYear, timeSliders, location, timeButtons, currentLocationButton} from "@roelandschoukens/inputs"
```
</details>
```{ojs}
import { calcuvizspec, calcudata } from "@declann/little-calcu-helpers"
embed = require('vega-embed');
main = require('https://calcy-quarty-vizys-online.pages.dev/models/heavens/sunsets.js')
introspection_fetch = await fetch(`https://calcy-quarty-vizys-online.pages.dev/models/heavens/sunsets.introspection.json`)
introspection = introspection_fetch.json({typed:true})
introspection_nomemo_fetch = await fetch(`https://calcy-quarty-vizys-online.pages.dev/models/heavens/sunsets-nomemo.introspection.json`)
introspection_nomemo = introspection_nomemo_fetch.json({typed:true})
inputs = Object.values(introspection.cul_functions).filter(d => d.reason == 'input definition').map(d => d.name).sort()
formulae = Object.values(introspection.cul_functions).filter(d => d.reason == 'definition').map(d => d.name)
// formulae excluding pure inputs
formulae_not_inputs = Object.values(introspection.cul_functions).filter(d => d.reason == 'definition' && inputs.indexOf(d.name+'_in') == -1).map(d => d.name)
```