Eplepresserioppgradering

Årets oppgradering i eplepresseriet er en fruktkvern. til erstatning for tidligere bruk av en vanlig kjøkkenmaskin

Eplepresseriet

Eplepresseriet

Eplekverna har kniver som kutter eplene og drar dem inn mellom valser som knuser dem.

Eplekverna har kniver som kutter eplene og drar dem inn mellom valser som knuser dem.

4 kg epler klar for kverning.

4 kg epler klar for kverning.

Den blir grovere enn ved bruk av kjøkkenmaskin, men det ser ut for å være en fordel ved pressingen

Kvernet fruktmasse. Den blir grovere enn ved bruk av kjøkkenmaskin, men det ser ut for å være en fordel ved pressingen

Etter to runder med pressing må det sies at dette var en svært god investering. Jeg plasserte kvernen oppå en plastkasse og satt en stor (ca 6 l) plastbolle nedi for å ta imot de oppmalte eplene.

  • Maler opp 4 kg epler på ca 2 minutter. Så kan eplene enkelt overføres til pressa. Kan nå enkelt presse 4×4 kg, tidligere var det ikke praktisk mulig med mer enn 4×3 kg.
  • Eplene malt opp på dette viset ser ut for å gi fra seg juice lettere. Tidligere har jeg måttet jobbe en del for å få ut 1 liter juice pr 2 kg epler, nå får jeg en drøy liter juice pr 2 kg epler med mindre arbeide med pressa
  • Enkel å rengjøre, spyles med hageslange etter at dagens arbeide er avsluttet
  • Sannsynligvis mer holdbar. Har alltid vært engstelig for at kjøkkenmaskinen skal bryte sammen når den må tygge gjennom 30-40 kg epler i løpet av noen få timer.
  • Ved oppkverning av store epler, kan det være nødvendig å dele dem opp, de kan bli liggende i forhold til knivene så de ikke blir ført ned mellom valsene
Posted in epler | 2 Comments

Postgres in python using flask-psycopg2

Not the most well-documented module I’ve ever seen…

To make it connect to your database of choise, in the app-settings, feed in

PSYCOPG2_DATABASE_URI=”pgsql://dbuser:dbpassword@dbhost/database”

e.g.

PSYCOPG2_DATABASE_URI=”pgsql://postgres:Secr1tPsswrd@localhost/postgres”

Posted in Diverse | Comments Off on Postgres in python using flask-psycopg2

.44 magnum cortado

Come on, make my coffee!

This coffee is strong enough to defend itself

This coffee is strong enough to defend itself

Posted in Diverse | Comments Off on .44 magnum cortado

Gymtider

Gymtimene på 80-tallet var for de sterke og minnene kommer strømmende på.

Gymlæreren min i 2. og 3. vgs hadde stor tro på at langdistanseløp var det eneste saliggjørende. Ut for 5000m på Bislett. Han sto på kanten og sekunderte. “14 etter 45:50” ropte han da jeg luntet forbi. “Hæ” svarte jeg, da jeg ikke hadde filla anelse om hva han mente (som jo tradisjonen var i gymtimer skal jo ikke noe forklares og jeg forsto ikke sekunderingen hans før mange år senere). Etter noen flere runder falt jeg ut av skjemaet hans. Jeg drev det også relativt langt til skulking i gymtimene etter at jeg hadde en skade å unnskylde det på. Jeg og en kompis kom oss helt til Tøyenbadet en gang vi hadde svømming, men endte opp i kafeen… “Hva om kommer nå?” sa kompisen “Da løper vi, da kjenner han oss ikke igjen” svarte jeg. Og kompisen holdt på å le seg i hjel – jeg forsto ikke før lenge etterpå at han hadde sett det absurde i at gymlæreren skulle se oss løpe, jeg tenkte bare på å skygge banen raskt nok.

Heldigvis var jeg alltid mest selvironisk i forhold til mine ytelser i gymtimene – men det var vel ikke det som var meningen med det hele?

Posted in Diverse | Comments Off on Gymtider

Client based web-mapping

Maps with R – part III shows how to make an active svg-map from R. In that example, a specialiced data set was used. I have redone it by using a map pulled in from postgis and also added on some more functionallity, some of it may be extened further to make a kind of client-based web-gis application. This examnple map uses a continous color scale for a map of discrete values. This is a bad idea, but is used here to simplify the example.

Moving the mouse pointer over the map shows a tooltip with some selected information for each polygon. When clicking on a polygon, the color changes and a callback to the web pages makes the web page show the ID of the polygon. This can of cource be used to show more information, possibly fetched through an ajax call.

The svg-map is prepared through R. A number of pakages must be loaded:
library(gridSVG)
library(sp)
library(lattice)
library(latticeExtra)
library(maptools)
library(colorspace)

I have a variable called “map” that is a map pulled in from a postgres database.
map=readOGR("PG:dbname=database user=username password=password",layer=<name of the table in postgis>)

Some parts must be prepared before the svg-export can be run:

grid.newpage()
set_Polypath(FALSE)
panel.str < - deparse(panel.polygonsplot, width=500) panel.str <- sub("grid.polygon\\((.*)\\)","grid.polygon(\\1, name=paste('ID', slot(map, 'data'\\)\\$gid\\[i\\], sep=':'))", panel.str) panel.polygonNames <- eval(parse(text=panel.str),envir=environment(panel.polygonsplot)) p <- spplot(map["category"], panel=panel.polygonNames) eval(p) set_Polypath(TRUE)

For other use, two lines must/ may be altered:
panel.str < - sub("grid.polygon\\((.*)\\)","grid.polygon(\\1, name=paste('ID', slot(map, 'data'\\)\\ $gid\\[i\\], sep=':'))", panel.str)

map is the name of the variable in which the map is stored.
gid is the name of the polygon id.
This lines makes an ID of each polygon that is made as "ID:" and the value of gid for each polygon.

p < - spplot(map["category"], panel=panel.polygonNames)

Again, map is the variable holding the map, category is the variable I want to be used for coloring the map.

Thereafter, the graphical objects (grobs) that we want to work on has to be enumerated:

## grobs in the graphical output
grobs < - grid.ls() ## only interested in those with "ID:" in the name nms <- grobs$name[grobs$type == "grobListing"] idxNames <- grep('ID:', nms) IDs <- nms[idxNames]


for (id in unique(IDs)){
# Need to get back the gid-value
x < - unlist(strsplit(id, 'ID:')) i=as.numeric(x[2]) # Looks up the map element with the corresponding gid n=which(map$gid==i) # Picks out values of category and shape_area for making the tooltip info=paste(id,"->",map$category[n],'(',map$shape_area[n],'m2 )')
g < - grid.get(id) ## attach SVG attributes # Defines attributes for the respective polygons. the javascript functions is defined in "tooltips.js" (see below) grid.garnish(id, onmouseover=paste("showTooltip(evt, '",info,"')"), onmouseout="hideTooltip()", onclick="mark(evt)", class=paste('cc',map$categorycode[n],sep=''), name=info) } # The file containing the javascript functions grid.script(filename="tooltip.js") svgname="svgtest.svg" gridToSVG(svgname)

This will produce the svg-file svgtest.svg and a very simple (too simple) html-file, svgtest.svg.html. The file tooltip.js must be available in the same directry as the svg.

The function mark(evt) is calling
parent.showalert(txt);
The parent object is the webpage that contains the svg-file, so the showalert(txt) function must be defined in that page. In this case, it is as simple as function showalert(txt){
document.getElementById('Showinfo').innerHTML=txt;
}

The page is available at http://sickel.net/misc/Geilo_annomap.svg.html

Possible further development:

* Click on an item in the legend to get all items of that class marked (they are already set to the same class)
* Fetch more information from a backend server when clicking (or for the tooltip)
* Change the color coding of the map (eg by fetching information from the backend

If this is to be run under R v 2.x, (e.g. on an older Ubuntu LTS) the available packages is lacking two functions, they may be provided through the following stubs:


grobDescent< -function(x=0,y=0,z=0){ return(unit(1,"npc")) } grobAscent<-function(x=0,y=0,z=0){ return(unit(1,"npc")) }

Posted in Diverse | Comments Off on Client based web-mapping

Om å lage en scene

Enhver hage med respekt for seg selv bør ha en festival fra tid til annen- og da trenges det en scene.

Vår scene blir bygget hovedsaklig av 2″x6″,det er mulig det kunne holdt med 2″x4″, men det var nå en gang 2″x6″ jeg hadde liggende første gangen vi skulle bygge scene. Scenen har en grunnflate på ca 5×4 meter (breddexdybde) og en høyde på ca 2.5 meter (må kunne gjøre en “hoppestopp”) På grunn av fasongen på plenen der den blir bygget, er den litt dypere på den ene siden enn på den andre.

Vi bygger først de to siderammene, deretter settes de opp med støtter i underkant, slik at bærebjelkene for taket kan legges opp.

I bakkant ble det bygget et trommepodium på ca 2×2 meter, for å sikre at dette ble stabilt, la vi bærebjelker relativt tett (ca 40 cm avstand)

Vi la opp en stående 2″x6″ i forkant for å bære taket. I bakkant la vi på en 2″x4″ i høyde med rammen, dermed ble det et fall på ca 15 cm over ca 2.5 meter. Stående 2″x6″ ble lagt i lengderetningen. Dette fallet ser bra ut, men det er litt lite for å få regnvann til å renne unna. Det er viktig å bruke en god presenning som kan strammes godt opp til tak dersom det er fare for nedbør. Det er også satt opp en bjelke bakerst på venstre side som ikke skal bære noe, men som definerer bakre hjørne på scenen.

Vi brukte to presenninger for å lage vegger. Den ene var bakvegg og høyre side (sett forfra) den andre var venstre side og overlappet et par meter på bakveggen. Ved å ikke feste bakveggen for mye i enden, ble det mulig å komme inn på scenen bakfra. En bagasjestropp rundt en av bjelkene ble brukt for å feste bakveggen og samtidig gjøre det mulig å åpne.

Tverrliggerene her er, sett forfra:
2″x4″ (ny) som bærer taket i bakkant.
Skrå lekt som er feste for bakveggen .
Rett lekt som er feste for avslutingen av venstre vegg.

Med presenninger på plass. Skrålekten holder bakveggen

Noen paller ble brukt som underlag for forsterkerene

En lekt festet i forkant blir feste for takpresenningen.

Taket må strammes godt opp i bakkant:

Klar for soundcheck:

og konsert:

Neste gang scenen settes opp, vil vi montere belysningen i fremkant av scenen.

Posted in Diverse | Comments Off on Om å lage en scene

Automatic datavalidation in postgres

I have a system that continously logs various environmental parameters at home. Occasionally one of the sensors delivers some wrong readings and I would like to stop them from showing up in analyses and plots. To do this, I am inserting the data through a function that autmatically flags data that have too high or too low values – too high and low being defined for each physical sensor.

The part of the database that helps me achieve this is defined as
create table measure(
id serial primary key,
value float not null,
sensorid integer references sensor(id),
use boolean not null default true,
timestamp datetime default now()
)

When I am using data, I am reading them from the view measure_qa defined as
create view measure_qa as
select * from measure where use=true

Data about each physical sensor is stored in table sensor:

create table sensor(
id serial primary key,
typeid integer references type(id),
name varchar not null,
maxvalue float not null,
minvalue float not null
)

and for each sensor type in table type:

create table type(
id serial primary key,
name varchar,
unit varchar)

To insert data, I have defined the function addmeasurement as

CREATE FUNCTION addmeasure(double precision, integer) RETURNS integer
LANGUAGE plpgsql
AS $_$ declare
sval float:=$1;
sid integer:=$2;
mx float;
mn float;

begin
select minvalue,maxvalue into mn,mx from sensor where id=$2;
insert into measure(sensorid,value,use) values(sid,sval,mnsval);
return 0;
end;
$_$;

By calling addmeasure with the reading and the sensor id as parameters, it will check the allowed max and min values for the actual sensor and .set the use-field accordingly – if the value is within the allowed span, it is true, else it is false – and the value will not be used. It could also be possible to add in validation if the value has been fluctuating too much within a given timespan – I may implement that later on. In that case, I must consider how long time has gone since the last valid data point has been inserted and how much the data should be allowed to change per time unit.

I could also have made the use-field a varchar field (or as a foreign key to a lookup table) – then I could have had e.g. “OK” as default value and the value for data that should be used later on, and I could have made a difference between data points that were automatically discarded and data points that I have manually marked as invalid.

A important, but potentially difficult part is to set the max and min values right. They should trigger on as many error as possible without flagging valid data as invalid. It might be useful to know how the various sensors fails. E.g. I am using some ds18b20 temperature sensors. If they are not initiated properly, they may return either -127, +85 or 0 °C. I live in a place where the outdoor temperatures may go below freezing for several month of the years, so for an outdoor sensor, I cannot automatically filter out 0°C errors, so I set the limits to -50 / +60 which is far outside observed temperatures here but for the indoors sensors, (which never should go below 15 or above 45, I can set the limits to 2 and 40 °C.

Posted in Data | Comments Off on Automatic datavalidation in postgres

How to move a VboxManager virtual machine to another host

Officially, this has to be done using the clone function in vboxmanager – but you may (as I did) come up in a situation where the virtualbox system in the original host for some reason is not usable.

I moved my virtual machine between two 64-bits linux systems (the original host running ubuntu, the new host running debian). First I copied the entire directory containing the vm from the old host to the new one. Then I had to look at the .vbox file in that directory (the vm is called dbserver) which starts like this:

< ?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.12-linux">
<Machine uuid="{29fc488f-7e02-4564-b407-373dd72731c3}" name="dbserver" OSType="Ubuntu_64" currentSnapshot="{bf8a6162-452f-4433-b0ac-20732c166748}" snapshotFolder="Snapshots" lastStateChange="2013-04-20T16:07:17Z">
<MediaRegistry>
...

The important part is the “Machine uuid” In the global settings file for vboxmanager, Virtualbox.xml, I had to add a line within the <MachineRegistry>


<MachineRegistry>
<MachineEntry uuid="{29fc488f-7e02-4564-b407-373dd72731c3}" src="/home/morten/VirtualBox VMs/dbserver/dbserver.vbox"/>

– then the vm could be started with the disks in the same state as it was on the old host.

There might be that I also should have added some information within <MediaRegistry>, but so far it seems to run just fine – and I can do a clone for backing up.

On the linux systems, the files for the vm are stored within ̃~/VirtualBox VMs/<vmname> – ie in my case ~/VirtualBox VMs/dbserver. The global settings file is ~/.VirtualBox/VirtualBox.xml – in other systems, it may be stored other places. – I have no idea if this will work to move a vm between two hosts with different OSs.

Posted in Data, linux | Comments Off on How to move a VboxManager virtual machine to another host

Sensor testing

After a DHT22 arrived a couple of days ago, I have had quite a few sensors running on my desktop:

  • DHT11 humidity and temperature sensor
  • DHT22 humidity and temperature sensor
  • BMP085 air pressure and temperature sensor
  • DS18B20 temperature sensor
All the sensors are situated close together.

DS18B20 in foreground. DHT11 (blue) at the back, DHT22 (white) in the middle and BMP085 (red PCB) at the right.

All the sensors are sampled at approximately 15 minutes intervals. The DHT11, DHT22 and BMP085 are all connected to the same controller and are sampled at the same cycle, The DS18B20 is connected to another system which may be sampling at other moments, although at the same frequency. (more information on the hard- and software for sampling can be found here)

Temperature
The DS18B20 is set up to 0.5 degree resolution. According to the documentation, this is consistent with the accuracy, although it may report values with a much higher resolution. The DHT11 is reporting temperatures with a 1 degree resolution the BMP085 and DHT22 both returns temperatures with a 0.1 °C resolultion. The temperatures from the last approx 36 hours seems to fit reasonably well.

The temperature curves fits reasonably well

Temperatures measured with different sensors

Relative humidity
When it comes to relative humidity, only the DHT22 and DHT11 can be compared. The DHT11 is reporting humitities with a 1% resolution and the DHT22 with a 0.1% resolution, so some differences are expected. But it turns out that the DHT11 seems to be a much poorer detector than the DHT22. It kind of gets the right humidity, but is really inaccurate.

The DHT11 shows a nearly straight line, varying between 35 and 36%, with a few jumps down to 34% at the start. The DHT22 shows a much larger span.

Relative humidity logged with a DHT11 and a DHT22.

Using just one detector of each kind, it is of cource difficult to give any general conclusions. By breathing on it, I can get the DHT11 to show a much higher relative humidity. It may be that one of my detectors is defective- but so far, it seems really to be worth it to shell out the extra to get a DHT22 rather than the DHT11.

Posted in arduino | Comments Off on Sensor testing

Fixing damaged pickguard

There should be some limits to stupidity – I tried to pick up my bass while the cable was plugged in and I was standing on the cable… It ended up with a broken pickguard:
The pickguard is broken, a piece has fallen out just above the jack

I don’t know how easy it is to find a new pickguard for an ’80 Ibanez so I decided to try to fix it. I needed something thin, strong and shapeable so I decided that a CD might fit the bill

IMGP0005_small

I drew the shape of the broken of piece of the pickguard on the CD and cut with a scissor along the line. To make things a bit easier for me, I centered the CD so that the jack fit through the centre hole.

IMGP0007_small

Having the template, I drilled a hole in the CD to be able to fit it temporary and find the shape for the rest of it.

IMGP0009_small

Then I could shape it

IMGP0010_small

and glue on the broken of part (note that I have leveled the upper end a bit of to make it fit a bit smoother.

IMGP0014_small

Then it was time to refit the jack

IMGP0017_small

and put it all togheter again.

IMGP0021_small

I don’t mind some “battle scars” on my bass, but this reminds me a bit too much of pure stupidity, so I may try to fix it up a bit more, maybe time to “borrow” some white nailpolish from some of the ladies in the house… (It can be seen that the pressure from the lowermost screw pushed it a bit out of shape)

IMGP0022_small

The old pickguard had a screening on the backside, that was of cource also broken. I have not (yet) noticed any increased noice, but I may take it a part and put on something later on (hah, famous last words). Either by gluing some tin foil to the back of the CD and the solder it to the old screening, or by refitting to screened cable from the jack.

Update – six months later: My fix turned out to be too unstable. I found out that it is no problem getting a new pickguard for fender basses, but not as easy for my ibanez, but I ended up ordering a new custom made one from Chandler music / pickguards.us – good quality and a perfect fit.

Posted in Diverse | Comments Off on Fixing damaged pickguard