Moon.mw

>

file: Moon.mw

===========

9. 3..2004

5. 6. 2004

------------------------------------------------------------------------

In this Worksheet, I discuss the derivation of the

Importance weights as function of the location size,

such that the label density on the screen remains constant

at all distances.

Typical applications will be the crowded locations on Mars, Venus and Moon

-------------------------------------------------------------------------

> restart;

libname :=

savelibname :=

> with(plots):

Warning, the name changecoords has been redefined

> with(stats): with(stats[statplots]):

The file 'Moon_sizes.txt' contains a 1-dim array of (nonvanishing) sizes [km]  of the 1857 locations for Moon . Read it into Maple:

> data:=readdata("Moon_sizes.txt",float):

Calculate log base 10 for each element:

> size:=evalf(map(x->log10(x),data)):

Histogram plot of log10(size) distribution:

> ph:=histogram(size,area=count,axes=boxed,labels=["log10(size)","number of labels"],labeldirections=[horizontal,vertical]):

> display(ph);

[Plot]

Extract the numerical values from histogram plot structure 'ph':

> Binwidth:=op([1,2],ph)[2][1]-op([1,1],ph)[2][1];

Binwidth := .4008722745

> dbx:=[];dby:=[];dbxy:=[];

dbx := []

dby := []

dbxy := []

> for i from 1 to 11 do

> dbx:=[op(dbx),op([1,i],ph)[2][1]+0.5*Binwidth];

> dby:=[op(dby),op([1,i],ph)[2][2]];

> dbxy:=[op(dbxy),[op([1,i],ph)[2][1]+0.5*Binwidth,op([1,i],ph)[2][2]]];

> end do:

> dbxy;

[[-.7995638628, 1.000000000], [-.3986915883, 3.000000001], [0.21806862e-2, 47.99999995], [.4030529612, 66.00000009], [.8039252352, 102.0000001], [1.204797509, 237.9999997], [1.605669784, 641.9999991],...[[-.7995638628, 1.000000000], [-.3986915883, 3.000000001], [0.21806862e-2, 47.99999995], [.4030529612, 66.00000009], [.8039252352, 102.0000001], [1.204797509, 237.9999997], [1.605669784, 641.9999991],...

> dbx;

[-.7995638628, -.3986915883, 0.21806862e-2, .4030529612, .8039252352, 1.204797509, 1.605669784, 2.006542059, 2.407414333, 2.808286607, 3.209158882]

> dby;

[1.000000000, 3.000000001, 47.99999995, 66.00000009, 102.0000001, 237.9999997, 641.9999991, 603.0000007, 128.0000002, 22.99999997, 2.999999998]

Compute the total number of non-vanishing location sizes in all 11 bins:

> GG:=j->sum(dby['i'],'i'=j..11);

GG := proc (j) options operator, arrow; sum(dby['i'], 'i' = j .. 11) end proc

> for j from 1 to 11 do

> GG(j);

> od:

> GG(1);

1857.000000

Aha, they sum up to the total count of (non-vanishing) location sizes in the data base.

Test on a Breit Wigner distribution of log10(size) around log10(s0),

> assume(v>0);

>

> dnLabels:=binwidth*nLabels_tot/Pi*v/((x-x0)^2+v^2);

dnLabels := binwidth*nLabels_tot*v/(Pi*((x-x0)^2+v^2))

> int(dnLabels/binwidth,x=-infinity..infinity);

nLabels_tot

OK, the distribution correctly  integrates to the total number

of Moon locations nLabels_tot = 1857 with non-vanishing size

> s0:=10^1.703;

s0 := 50.46612976

> pt:=plot(subs(binwidth=Binwidth,nLabels_tot=1857,x0=1.703,v=0.34,dnLabels),x=-1..4.5,color=red,thickness=2):

> display({ph,pt},labels=["log10(size)","Number of Labels"],labeldirections=[horizontal,vertical], title="BreitWigner distribution of log10(size) around size0=50.466Km", titlefont=[HELVETICA,20]);

[Plot]

OK, not perfect, but quite well compatible with a Breit Wigner distribution...

-------------------------------------------------------------------------------------

Next, want to derive the Importance weights I,

such that the label density on the monitor remains always constant!

-------------------------------------------------------------------------------------

Strategy:

=======

i) Let  nLabels = (number of visible labels) at distance d of our object (Mars, Venus, Moon...),

  having an  area A(d) = (const/d)^2 on screen in [pix^2].

  =============================================

  Require that the visible label density is about constant

  at all distances d [FoV's] of our object, i.e  

  

  nLabels/A(d) = const*nLabels*d^2 = constant

  =============================================

ii) For the given monitor resolution, and a range of 'importance weights I',

   determine empirically the distances d = d_vis(I) of our object, for which

   the associated labels just become visible.

   It is a linear relation as expected (see below).

  

   d_vis = 14.8 +86.9*I  [km]

 

  Thus the requirement of a constant label density turns into a formula

  for the importance weights I

 

  I = const/sqrt(nLabels)-Float(148, -1)/Float(869, -1)

iii) On Earth I calculated nLabels = nLabels(population) from

   the known data on city populations. For Mars, Venus,...

   we may as well take the number-distribution of the

   location sizes.

  Above we obtained approximately a Breit Wigner distribution

  nLabels = Normal(log10(size))

  around an average location size of s0 = 50.46 km.

iv) We may feed this in and determine the only unknown constant

    by requiring a convenient number of visible labels at a certain

    distance of the object. E.g.  for Earth, 10/hemisphere  at a distance

    of 40000 km.

-------------------------------------------------------------------------

Our problem of expressing the weights as function of the known location sizes

such as to keep the label density on the screen constant,  is solved!

Let's get quantitative:

> distance:=[187,325,520,999,2085,6107,9835,15708,24880,33900];

distance := [187, 325, 520, 999, 2085, 6107, 9835, 15708, 24880, 33900]

> importance:=[2.2,3.84,6.11,11.49,24.08,70.13,112.72,178.9,285.68,391];

importance := [2.2, 3.84, 6.11, 11.49, 24.08, 70.13, 112.72, 178.9, 285.68, 391]

> distimp:=[[2.2,187],[3.84,325],[6.11,520],[11.49,999],[24.08,2085],[70.13,6107],[112.72,9835],[178.9,15708],[285.68,24880],[391,33900]];

distimp := [[2.2, 187], [3.84, 325], [6.11, 520], [11.49, 999], [24.08, 2085], [70.13, 6107], [112.72, 9835], [178.9, 15708], [285.68, 24880], [391, 33900]]

> q0:=pointplot(distimp,symbol=BOX,color=blue,symbolsize=20):

Again: least square fit of linear relation: min. distance <=> Importance weight

> fit[leastsquare[[x,y],y=a+b*x]]([importance,distance]);

y = 14.82791092+86.91039073*x

> q1:=plot(14.82791092+86.91039073*imp,imp=1..1000,color=red,thickness=2):

> display({q0,q1},axes=boxed,labels=["Importance weight","min. distance [ km ], where visibility starts"], labeldirections=[horizontal,vertical]);

[Plot]

Aha, an excellent fit!

--------------------------

Next, since we want the total number of visible labels for a given log10(st)= xt,

we must divide by the binwidth and integrate from xt to 'infinity' (all labels corresponding to a bigger size  than xt are also visible!):

> Ltot:=subs(binwidth=Binwidth,nLabels_tot=1857,x0=1.703,v=0.34,Int(dnLabels/Binwidth,x=xt..infinity)=int(dnLabels/Binwidth,x=xt..infinity));

Ltot := Int(631.3800000/(Pi*((x-1.703)^2+.1156)), x = xt .. infinity) = 591.1014587*arctan(-2.941176471*xt+5.008823530)+928.5000001

Define a function from the result:

> nLabels:=rhs(Ltot);

nLabels := -591.1014587*arctan(2.941176471*xt-5.008823530)+928.5000001

Let's see what the total number of labels becomes? 1857?

> evalf(subs(xt=-infinity,nLabels));

1857.000000

YES, indeed!

Plot the integrated number of totally visible labels vs. xt=log10(st):

> logplot(nLabels,xt=-1..6,OPTS,labels=["xt=log10(st)","number of  visible labels for sizes >xt"],labeldirections=[horizontal,vertical],axes=boxed);

[Plot]

Next we calculate the Importance weights, as outlined above, from

> Importance:=expand(solve(nlabels=(c/(14.82791092+86.91039073*imp))^2,imp)[1]);

Importance := -.1706114861+0.1150610406e-1*c/nlabels^(1/2)

c is the constant to be determined e.g.  from the requirement of seeing 10 labels (5/hemisphere) at a distance of 40000km:

For general c, we get:

> solve(nLabs=(C/40000)^2,C)[1];

40000*nLabs^(1/2)

====================================Final Result =================================================

> Imp:=evalf(subs(nlabels=nLabels,xt=log10(s),c=40000*nLabs^(1/2),Importance));

Imp := -.1706114861+460.2441624*nLabs^(1/2)/(-591.1014587*arctan(1.277336712*ln(s)-5.008823530)+928.5000001)^(1/2)

==============================================================================================

> w1:=loglogplot(subs(nLabs=5,Imp),s=0.1..10000,axes=boxed,labels=["Size [km]","Importance Weight"],color=blue,numpoints=5000):

> w2:=loglogplot(subs(nLabs=1,Imp),s=0.1..10000,axes=boxed,labels=["Size [km]","Importance Weight"],color=red,numpoints=5000):

> w3:=loglogplot(subs(nLabs=0.5,Imp),s=0.1..10000,axes=boxed,labels=["Size [km]","Importance Weight"],color=green,numpoints=5000,labeldirections=[horizontal,vertical]):

> display({w1,w2,w3});

[Plot]

>

-------------------------------------------------------------------------------------

This solves the problem, the above function is entered into my Perl script

which assigns the Importance weights accordingly!

--------------------------------------------------------------------------------------