## Import Access Data into Excel (via VB and ADO)

I had a lot of data in MySql in a rails application, but I moved to Mongo on a new application and wanted to give the client a nice archive of excel files for each client. It has been a long time since I’ve worked with visual basic, but it came back quickly.

I was amazed how clunky the interface and I wrote some pretty redundant code, but this was my Saturday and I tried to get this out the door quickly. My basic workflow was to load an office trial version on a virtual machine, then install SQL server on windows and set up an ODBC connection string which I used to import all data into access. In access, I just wrote a bunch of sql strings and used access to automate excel via VBA.

https://gist.github.com/tbbooher/2386826

## Get congressional district data to display on d3.js

I’m trying to get congressional district data to display on d3.js so I can do some cool overlays. The trick is to get matlab to comply.

## UTAPS: Mark an IDT as complete

UTAPS is terrible software. I wasted a half hour today going through the source code to figure out how to mark an IDT as complete.

I have no idea how folks who don’t understand web codes can navigate this system.

Why not include a button? Really?

## Your key with fingerprint … is not authorized to access heroku with Ubuntu

This error was pretty hard to solve. I emailed heroku support and they recommended:

“https://github.com/ddollar/heroku-accounts”:https://github.com/ddollar/heroku-accounts

bq. For git commands to work git needs to use the ssh key associated with that account. It’s probably choosing a key associated with a different account which is causing these permissions errors. You can use a ~/.ssh/config file to specify which key should be used. Check out this client plugin written by one of our engineers. It helps manage both Heroku credentials and ssh keys for easy switching between accounts. https://github.com/ddollar/heroku-accounts Please let me know if you have more questions.

Their comment did make my future work with multiple accounts easier — it didn’t solve my problem which was that my old fingerprint was still active, and causing trouble.

The solution for me was not to create and provide a new key to heroku. It was to go to the gnome passwords and keys folder and manually delete “My Personal Keys”.

See this comment from “launchpad”:https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/505278 for details.

bq. The culprit is gpg-keyring-daemon. It subverts the normal operation of ssh-agent, mostly just so that it can pop up a pretty box into which you can type the passphrase for an encrypted ssh key. And it paws through your .ssh directory, and automatically adds any keys it finds to your agent. And it won’t let you delete those keys. How do we hate this? Let’s not count the ways — life’s too short.

bq. The failure is compounded because newer ssh clients automatically try all the keys in your ssh-agent when connecting to a host. If there are too many, the server will reject the connection. And since gnome-keyring-daemon has decided for itself how many keys you want your ssh-agent to have, and has autoloaded them, AND WON’T LET YOU DELETE THEM, you’re toast.

bq. What you really want to do is to turn off gpg-keyring-daemon altogether. Go to System –> Preferences –> Startup Applications, and unselect the “SSH Key Agent (Gnome Keyring SSH Agent)” box — you’ll need to scroll down to find it.

bq. You’ll still get an ssh-agent, only now it will behave sanely: no keys autoloaded, you run ssh-add to add them, and if you want to delete keys, you can. Imagine that.

## Render CSV in Rails

First I read the docs at: rubydoc.info to understand how FasterCSV is now in the ruby standard library.

Then, I set up the following code:

https://gist.github.com/tbbooher/1700200

This gives me a pretty flexible solution to render csv, but I’m really interested to see if this is a good way to go. Your comments are appreciated.

## Radar parameter estimation

Here we tackle what a Radar needs to accurately measure a target’s position, size and motion. (This is nothing new, just a placeholder for some of my notes.)

First of all, everything depends on $SNR$, and the parameter estimation happens in the main computer of a Radar. The theoretical rms error of a measurement is of the form:

where $$k$$ is a constant between 0.5 and 1.

h3. Range

First, let’s tackle range. They key metric for range is bandwidth, the higher the bandwidth the better the resolution.

Estimation of the range of a target is based upon using A/D sampled measurements of the round trip time to and the target

For time delay measurements , such as range, the value of the constant depends on the shape of the radar pulse’s spectrum and the pulse’s rise time and for a rectangular pulse, whose width is, (T):

or equivalently,

However, pulses always move in trains or if $T_D$ is the dwell time:

from Barton and Ward.

So Range depends on $$SNR$$, pulse shape and width, effective bandwidth, number of pulses that can be coherently integrated.

This is explained well by a diagram in the lincoln presentation:

h3. Angle

Now, let’s tackle angle. Angle accuracy depends on antenna size. Simple detection provides coarse location in angle by isolating a target’s location within beamwidth of antenna (and beamwidth is just $$\lambda / D$$, where $$D$$ is the aperture diameter and $$\lambda$$ is the wavelength. But this is very coarse, 1° beam at 100 km extends across 1,745 meters. In order to provide more accurate angle estimation, you have to measure at different beam positions to improve accuracy. You can do this through sequential lobing, conical scan tracking, or monopulse angle estimation.

h4. Conical Scanning

Conical scanning is a technique to keep the beam pointed at the target to improve angle accuracy. It is based on the principle that the radar receiver will get maximum returned signal strength when the target is in the beam centre, so if the beam is pointed directly at the target, when the target moves it will move out of the beam center and the received signal strength will fall. Circuitry designed to monitor any fall off in received signal strength controls a servo motor that steers the aerial to follow the target motion.

Wikipedia has a nice drawing that explains this technique:

h4. Sequential lobing

While conical scan tracking uses the phase of modulation to get the angle error and amplitude modulation to get the beam displacement, sequential lobing uses two slightly separated antenna elements to send the beam slightly to either side of the midline of the antenna, switching between the two to find which one gave the stronger return, thereby indicating which direction the antenna should be moved in order to point directly at the target.

Here, wikipedia provides another good diagram:

h4. Monopulse

Monopulse radars are similar in general construction to conical scanning systems, but add one more feature. Instead of broadcasting the signal out of the antenna “as is”, they split the beam into parts and then send the two signals out of the antenna in slightly different directions. When the reflected signals are received they are amplified separately and compared to each other, indicating which direction has a stronger return, and thus the general direction of the target relative to the boresight. While monopulse, requires a separate receiver for each channel, it improves performance over conical scan and sequential lobing whose performance degrade with time varying radar returns.

All angle errors are summed up well by the following:

and

SNR, type of measurement technique, antenna illumination distribution, antenna size, and frequency.

h3. Doppler

Lastly, let’s look at Doppler accuracy. Doppler accuracy depends on coherent integration time $$\Delta t$$:

Doppler frequency is calculated as:

To accurately measure Doppler, use two closely spaced frequency filters offset from the center frequency of the Doppler filter containing the detection

Doppler accuracy depends on SNR, pulse shape, integration time.

h3. Real world limitations

# Adds variance to estimates

# Poor calibration leads to poor estimation

h4. Amplitude fluctuations

# Small effect on monopulse and array solutions

h4. Angle noise (angle scintillations, or target glint)

# Complex target return biases angle estimate

h4. Multipath (low angle tracking)

# Reflection off earth’s surface combines with direct path return

# Can cause biases in angle estimates for all technique

h4. Good References

## Wind speed calculation

I want to know the impact of wind on endurance.

So we have something like this:

This gives us 8 cases of wind direction:

From this we can infer that going to the center from one of the 8 directions.

So an overall flight path would look like this:

If each grid cell is a distance (s) in size, each time a diagonal transition is made the distance would be (sqrt{2} s). As an aircraft enters each cell, they encounter the wind-star as shown above with the expected value of the wind facing one of the eight possible directions. In general, if (W) is the wind velocity in direction (alpha), from grid direction (g in [1,8]) we have to find the expected value for the wind in direction (cos(alpha_{g,w})), by integrating over all values of (w).

[
V_{g,w} = sum_{1..12} cos(alpha_{g,w_{i}}) dot P_i
]

With these bins:

h3. Wind Directions ( w_{i} )
|Wind Direction|Angle|
|1|0|
|2|30|
|3|60|
|4|90|
|5|120|
|6|150|
|7|180|
|8|210|
|9|240|
|10|270|
|11|300|
|12|330|

h3. Grid Direction (g)
|Grid Direction||
|1|315|
|2|270|
|3|225|
|4|0|
|5|180|
|6|45|
|7|90|
|8|135|

## Buyback military years

h2. Should I even buy the years? what if we use the 13K for something really special? the cashflow is way out there.

 1 36 7836.44 2 37 8692.42 3 38 9592.71 4 39 10539.2 5 40 11533.8 6 41 12578.7 7 42 13675.8 8 43 14827.4 9 44 16035.9 10 45 17303.5 11 46 18632.7 12 47 20026.1 13 48 21486.3 14 49 23016.2 15 50 24618.4 16 51 26296.1 17 52 28052.3 18 53 29890.3 19 54 31813.2 20 55 33824.6 21 56 35928.1 22 57 38127.3 23 58 40426.2 24 59 42828.6 25 60 45338.9 26 61 47961.2 27 62 50700 28 63 53560 29 64 56546 30 65 59662.9

If you’ve spent time in on active duty with an honorable discharge (i.e. you have a DD-214) and you then join the civil service, it is possible to pay for your military years and receive credit for FERS.

Questions:
* What are the various deadlines?

There is a two-year interest free period that begins on your date of hire. However, since the interest is added on an annual basis, if the deposit amount is paid in full prior to three years of your hire date the deposit is interest.

* Can I collect my civilian and reserve retirements? (Retirement: You must waive your military retired pay in order to receive credit for military service in a civilian annuity, unless your military retirement is based on)
*

employee. The deposit can be made in one single payment, multiple payments, or through payroll deductions, normally for as little as $25-$50

There are two reasons to do this:
* You could retire sooner, or
* Your can increase your retirement annuity

Here are the rules:
* The deposit must be paid in full while you are a federal employee
* that you must have at least five years of creditable civilian service and be covered under the CSRS or FERS retirement system on the date of retirement

All the details are here: “http://www.opm.gov/retire/pre/fers/servicecredit.asp”:http://www.opm.gov/retire/pre/fers/servicecredit.asp

Here is the math. The deposit amount is 3{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4} of military base pay for FERS employees.

There are three steps to make this happen:

Obtain your total estimated military earnings by sending form RI20-97 and a copy of your DD214 to your respective military pay representative. The military payroll office will send you a short letter or form indicating your total estimated earnings during your military service.

Complete a SF-3108 or SF-2803 This form requires a statement on the form concerning military deposits, which is not available on the on-line version. Obtain the edited form from your HR office. HR will forward the documents to your civilian payroll office. Your payroll office will bill you directly.

Make the deposit to your civilian payroll office. You can pay the deposit in one lump sum, a series of payments, or sign up for payroll deductions, normally for as little as \$50 per pay period. The deposit must be paid in full while you are employed and cannot be made after you retire.
Step 4: When the deposit is complete, your payroll office will send you a letter that the deposit is paid in full. Keep this document for your permanent retirement records and send a copy to your HR office. Payroll will not usually notify your HR office of the deposit, so it is very important that you retain a copy of this letter until you

classdef PaymentPlanner  0
obj.year_of_departure = 2011 + years_from_now;
end
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           how many years are we looking at total?
obj.n                       = PaymentPlanner.years_out+1;
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           which years are we looking at?
obj.years                   = (2011:(2011+PaymentPlanner.years_out))';
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           what are the years of the experiment?
obj.tv_each_year            = obj.years;
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           what age are you each year?
obj.tv_age                  = obj.years-(ones(obj.n,1)*1976);
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           what is your age when you leave service?
obj.year_of_62              = obj.years(obj.tv_age == 62);
obj.age_at_departure        = obj.year_of_departure-obj.birthday(1);
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           what is the inflation-adjusted salary in each year?
obj.tv_salary               = obj.increase_with_inflation(obj.starting_salary)';
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           what is the inflation-adjusted salary at exit
obj.departing_salary_TY     = obj.tv_salary(obj.years == obj.year_of_departure);
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           how much cash on hand each year?
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           how many years in federal service?
obj.total_time_in_service   = obj.year_of_departure - PaymentPlanner.year_started_service;
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           how much cash would the government return?
obj.payout                  = calculate_payout(obj);
{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}           what is the yearly payment available in 2011 dollars?
obj.yearly_payment_BY       = obj.present_value(obj.get_retirement_BY, obj.year_of_62 - obj.year_of_departure);
end

function compare_30_year_coa(obj)
for i = 1:30
obj.year_of_departure = 2011 + i;
obj.age_at_departure  = obj.year_of_departure-obj.birthday(1);
obj.total_time_in_service   = obj.year_of_departure - PaymentPlanner.year_started_service;
obj.yearly_payment_BY       = obj.present_value(obj.get_retirement_BY, obj.year_of_62 - obj.year_of_departure);
disp([num2str(i) '|' num2str(obj.age_at_departure) '|' num2str(obj.yearly_payment_BY)]);
A(i) = obj.yearly_payment_BY;
end
plot(1:30,A);
end

function out = present_value(obj, x, years)
out = x/((1+obj.inflation_rate)^years);
end

function out = increase_with_inflation(obj,x)
out = x*((1+obj.inflation_rate).^(1:obj.n));
end

function display_output(obj)
disp(['At age ' num2str(obj.age_at_departure) ' you would depart with a base year salary of ' num2str(obj.starting_salary) ]);
disp(['You would get ' num2str(obj.yearly_payment_BY) ' (BY11) going forward at age 62.']);
end

function payout = calculate_payout(obj)
idx                         = find(obj.tv_age == 62);
count_to_the_top            = length(obj.tv_payout_TY(idx:end));
retirement_starting_salary  = obj.get_retirement_TY;
obj.tv_payout_TY(idx:end)   = retirement_starting_salary*(1+obj.inflation_rate).^(1:count_to_the_top);
payout                      = sum(obj.tv_payout_TY);
end

function yearly_payment = get_retirement_TY(obj)
yearly_payment      = (obj.total_time_in_service/100)*obj.departing_salary_TY;
end

function yearly_payment = get_retirement_BY(obj)
yearly_payment      = (obj.total_time_in_service/100)*obj.starting_salary;
end

function obj = value_at_age_62(obj)

end
end

end



h2. What are the steps?

Do I fall under: Uniformed Services Employment and Reemployment Rights Act (USERRA)?
No because no civilian service was interrupted.
How much do I pay?
For periods of service performed during 1999 the deposit equals 3.25{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}; and during 2000 the deposit equals 3.40{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}. After 31 Dec 00 the deposit returns to 3{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4} of your military base pay.
For periods of service performed during 1999 the deposit equals 3.25{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}; and during 2000 the deposit equals 3.40{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4}. After 31 Dec 00 the deposit returns to 3{aaa01f1184b23bc5204459599a780c2efd1a71f819cd2b338cab4b7a2f8e97d4} of your military base pay.
So, for example, I joined in 07/04/1999 and departed in 08/05/2009
What is the process

## Resource Allocation with Approximate Dynamic Programming

[
E = frac{eta}{c}left( frac{C_L^{3/2}}{C_D} right) sqrt{2 rho S} left( frac{1}{W_f} – frac{1}{W_i} right)
]

Where (eta) is the propeller efficiency, (c) is the minimum power specific fuel consumption rate, maximum density of air, ( rho ).

## Winds around the world

Goal: characterize the winds available around the world.

First we need to construct our grid:

The horizontal, latitude-longitude grid ranges from +70 to -70 deg in latitude and from 0 to 357.5E deg in longitude, producing a grid that has dimensions of 57 x 144 points.

In matlab, this is:

[cells/degree northern_latitude_limit western_longitude_limit]

zerom(


These data were produced from the “NCEP/NCAR Reanalysis”:http://www.esrl.noaa.gov/psd/data/reanalysis/reanalysis.shtml are available at six-hour intervals, from January 1, 1948 to the present, and it is this 6-hour data that was used as the basis for this work.

Spatially, the delivered data values are given at points in a three-dimensional, global system using a 2.5 x 2.5 deg grid of latitude-longitude and altitudes that are specified by atmospheric pressure.

Above each point in this grid, horizontal wind information is delivered at 4 pressure levels: 50 mb, 70 mb, 100 mb, and 150 mb. If we assume a standard day, this corresponds to: 67,726 60,504 53,083 44,647 feet. At each grid point and pressure altitude, the horizontal wind vectors have been sorted into 12 directional bins.

Cells per degree = 2.5
Degrees per cell = 0.4


– how linear is the wind change with altitude?
– where are winds high?