Showing posts with label work. Show all posts
Showing posts with label work. Show all posts

12 November 2018

My Very First R Script!

After over a decade of always defaulting to Matlab for all my data processing tasks, I finally work at a place that does everything in R - and I finally have an excuse to learn it. So, behold!

envdist = read.csv("EnvDist-Input.csv")
testdist = subset(envdist, Country == "ISR" | Country == "FJI")

distance <- matrix(data = 0, nrow = nrow(testdist), ncol = nrow(testdist) )
rownames(distance) <- testdist$PortName
colnames(distance) <- testdist$PortName

for (i in 1:nrow(testdist)) {
  for (j in i+1:nrow(testdist)-i) {
    # d(a,b) = sqrt( (a1-b1)^2 + (a2-b2)^2 + (a3-b3)^2 + (a4-b4)^2 )
    distance[i, j] <- sqrt(
    (testdist[i,5] - testdist[j,5])^2 + 
      (testdist[i,6] - testdist[j,6])^2 +
      (testdist[i,7] - testdist[j,7])^2 +
      (testdist[i,8] - testdist[j,8])^2 )
    }
  }
print(distance)

It does some fancy math to four columns of numbers and puts the result into a matrix.

The general point of this exercise is to compare environmental similarities between each and every port in the world, based on temperature and salinity. There are over 6600 ports to compare between, so when I do the real run, the matrix will be very large... but for starters, I just needed to make a functional FOR loop in R.


12 July 2011

Behold, Some Code!

Since my life reboot, my leet code skillz have gone to whole new levels. Here's a representation of the kinds of things I've been doing for the past three months:

s = 1; %blort-cell counter
interpnum = cell(1,6);
for t = {East_u, North_v, Vert_w, VelError, Mag, DIR}
    blort = t{1};
    k = 1; %within blort-cell counter
    for i = 1:length(SerYear)
        badeast = find(isnan(blort(i,:)));
        for j = 1:length(badeast)
            m = badeast(j);
            while isnan(blort(i, m))
                if m > 1
                    m = m - 1;
                else
                    break
                end
            end
            n = badeast(j);
            while isnan(blort(i, n))
                if n < SerBins(end)
                    n = n + 1;
                else
                    break
                end
            end
            interpnum{s}(k, 1) = i;
            interpnum{s}(k, 2) = badeast(j);
            if n - m < 5 && ~isnan(blort(i, m)) && ~isnan(blort(i, n))
                interpnum{s}(k, 3) = interp1([m n], [blort(i, m) blort(i, n)], badeast(j));
            elseif n - m < 5 && isnan(blort(i, m)) && ~isnan(blort(i, n))
                interpnum{s}(k, 3) = blort(i, n);
            elseif n - m < 5 && ~isnan(blort(i, m)) && isnan(blort(i, n))
                interpnum{s}(k, 3) = blort(i, m);
            else
                interpnum{s}(k, 3) = NaN;
            end
            k = k + 1;
        end
        clear badeast j m n
    end
    clear i blort k
    s = s+1;
end
badeast = interpnum{1};
badnorth = interpnum{2};
badvert = interpnum{3};
baderr = interpnum{4};
badmag = interpnum{5};
baddir = interpnum{6};
clear s t interpnum

It looks at a big block of numbers, one row at a time, and interpolates for any missing values - assuming that there are no more than four missing in a row (in the row). It does this for six individual same-sized blocks.

It's in Matlab. There might actually be a simpler way to do this, but if so I don't know about it. (Obviously.) The fun part is: it only took me two days to work all that out. Leet skillz progress! :D

20 May 2011

Things Learned from a Gulf of Mexico Science Conference

One

The preliminary results are in on the Deepwater Horizon oil spill.

There basically wasn't any hugely negative impact to wildlife in the immediate aftermath of last summer's oil spill. Some stuff died because the oil was toxic, but other stuff stepped right up because the oil was food. A lot of stuff that looked like it ought to be affected ... wasn't. The stuff that was knocked down recovered within a few months after they capped it. In short, some short-term changes in ecological composition occurred, but no overall increases or decreases of anything.

Also, commercially important fish had an outstanding year due to the lack of commercial fishing.

This is not to say that the Gulf ate the oil and is just fine now. Although there weren't immediate effects, the oil is still there and will likely have longer-term chronic effects. Some fisheries might not collapse until a couple years later, depending on how long the life cycles work for the seafood involved.

Two

The next time I find myself on the job market, all I really have to do is show up to a science conference and talk to people about what I can do with their CTD data. Voila, jobs will magically appear! Send out resumes? Phhht.

30 April 2011

Life is Grand Again

Part of my view into work:



Yes, I think in terms of workplace, I've definitely traded up. :)

Also, in the hopes that I really am about to resurrect this blog, a picture of a cat:



Specifically, it's this cat. I got back in touch with his owner, who sent me a more recent picture. Ten years later he's doing well and looks the same. :)

09 April 2011

From GA to AL via IN

BEFORE

I loved my work and my boss, I liked most of my coworkers, and I had come to hate my workplace.

AFTER

I'm doing the same work that I still love, so far I like my boss and coworkers, and I love my workplace.

All in all, despite two very strange years in between, I think I've traded up. :)

11 April 2010

Two Roads Diverge in a Wood, and I

On one side lies the Science Academia path. I can get another job as a data analyst and continue my endless string of research tech jobs. Or, if I want to actually advance, I can get a PhD in something. So far I've narrowed the "something" down to ecology, which is still kind of broad. Then, once I have a PhD, expectations rise steeply about what I do next: develop a research program and find ways to fund it. This would be exactly what I was avoiding for the past ten years.

On the other side lies Freelance Writing. Bright Hub has seemingly endless stuff for me to do, and it's certainly a place where I can help them grow. There are lots of other content sites I can write for as well. For that matter there's "real" freelance writing where I query to write stuff for a lot more money than content sites pay. The pay is very low at the start, but then there are my friends with the seafood market who have offered to let me move into their house for free room and board - so I'll stop having any living expenses to speak of. And just as I was waffling about where I should go, eHow folded up its ad-revenue-share program, and suddenly I'm a part of Demand Studios. Suddenly I can actually make decent money at this.

To go one way, I'd really need to find the right kind of passion for my work. Good scientists don't just go to work, they live and breathe what they study. I don't have that.

To go the other way, I'll basically lose all my credentials to go back to science later. My degrees are already stale, and my leet skillz will go too. I won't be able to go back.

Two roads diverging. I can't keep going up the middle or I'll just hit a tree. I don't know that the one I'm choosing is the less travelled, but it certainly seems to be the path of least resistance.

04 March 2010

Still Dwelling


You have killed me by Morrissey


I don't share this view of how things ended, but this is how I would respond to it. But then, it's not forgiveness from me that matters.

07 July 2009

The World Is My Oyster

On the one hand, I'm going to miss this place. I enjoyed being able to do whatever I wanted whenever I wanted, so long as 40 hours worth of work got done each week. I enjoyed the scenery to, from, and during work, the relaxed pace and lack of stress. I enjoyed everything about living here, as it gave me the time I needed to rest, regather, and redefine who I am. It's been a good eight years.

But on the other hand, it's time to move on. It has been time to move on for almost a year, in fact. What once was solace has slowly become limitations and fetters. What once didn't matter now does. I can't keep pets, I can't grow gardens, I can't do a lot of things involving money that I don't have, and I'm increasingly disgruntled with the way I'm treated at my workplace. It's no longer enough just to survive. I'm rested, and now I want to live.

And so, after I got over the initial shock of being canned due to a lack of grant funds, now that I am no longer bound by honor to finish the work I've started here, what I most feel is freedom.

30 June 2009

But I don't know how to leave you

And so the knight in shining armor, who spent the last six years never having time to be with the princess that he worked so hard trying to keep, failed. And the shared dream came to an end, even though it was never like that at all.

I don't know what I can say or do to make it better. I'm sorry too. And I still love you anyway.



I wish you could come with me.

13 June 2009

A Week in the Life of a Desk Jockey Oceanography Tech


A2009129180500_Composited_map.hdf

A2009130184500L2_map.hdf


These images show an estimate of chlorophyll levels off the coast of the southeastern U.S., on a log scale from 0.1 to 10, at a resolution of 1 km per pixel. Yellow is high, blue is low. About half of my job description involves making and sorting satellite images like these. I have several thousand of them, dating as far back as late 1997, showing all sorts of things about the ocean just off the coast (another example: sea-surface temperature (SST)). (And just to be clear, these images aren't coming off of military spy satellites or anything impressive like that, they're not classified, most of the data is freely available off the Internet. Nobody dangerous cares about this kind of scientific data. :) )

Then one day my boss said: "Can you get an estimate of cloud cover?"

And I thought: cloud cover. All I have to do is count up all the pixels representing the clouds, divide by the total number of pixels, and voila - percent cloud cover! Should be simple!

Yeah.

1. Grabbing the pixels to be counted

The first thing I did was to draw a line around the area I wanted to count. In this case, I figured he wanted basically the entire South Atlantic Bight (from Cape Canaveral to Cape Hatteras (aside: the name is a bit misleading, since the area isn't actually in the southern Atlantic Ocean, it just happens to be south of the Mid-Atlantic Bight (Cape Hatteras to Cape Cod). Ahh, Northeastern USian centrism.)) - from the shoreline to the edge of the continental shelf.

Getting the offshore side was easy enough, since I had a dotted yellow contour line for 500m depth already, and I could just follow that. Land, however, was a bit trickier, since I wasn't about to try following the shoreline pixel-by-pixel by hand. And inconveniently, the (usually large) negative number representing clouds is the same as the negative number representing land, which means there's no way to separate the two.

On the other hand, the most recent versions of seadas like to guess wildly at what sea surface temperature might be under the clouds. This is officially called "interpolation" - but what actually happens is a mess of processing artifacts that look like oddly shaped cold spots in strange places. (There's a few in my above SST example, lower right of the image; I picked that particular image at the time for its lack of the artifacts, though.) Most of the time it's annoying, as we like nice, solid black clouds that look like obvious clouds, like in the second chlorophyll image up top. But for land vs. cloud separation purposes, having clouds pretending to be strangely cold patches of the sea worked in my favor.

I picked a reasonably clear SST image, overlapped my line onto land, let seadas fill the whole thing in, and ended up with a blotch of 141,290 coordinate points like so:

(as plotted on a bathymetry image)

Then I fed it to Matlab and told it to strip out all points representing land:

fid = fopen('polishedblotch.dat','w');
for i = 1:length(sst)
if sst(i) ~= -163.835
fprintf(fid, '%6.3f ',blotchtemplate(i, 1));
fprintf(fid, '%6.3f ',blotchtemplate(i, 2));
fprintf(fid, '%6.3f\n',blotchtemplate(i, 3));
end
end
fclose(fid);

... which gave me:

(blue = before, green = after)

2. Grabbing the actual data

Now that I had a blotch with all the coordinates I wanted to count, it was time to get some actual data. So I wrote some IDL:

fnames=FINDFILE('/75-char-filepath/*hdf')
cnt = N_ELEMENTS(fnames)

for ctr = 0, cnt-1 do begin & $
load, fnames(ctr), ftype = 'MAPPED', prod_name = ['Mapped - chlor_a', 'Mapped - chla'] & $
out_track, iband=1, ifile = 'polishedblotch.dat', ofile = STRMID(fnames(ctr), 75, 8) + 'blotch_chl.txt', /no_connect & $
clear_up & $
endfor

It takes in files with names like A2009130184500L2_map.hdf, and puts out files with names like A2009130blotch_chl.txt. Notice that I'm going for chlorophyll here instead of SST. This is because chlorophyll has real clouds. Also, out of all the possible things I could use, chlorophyll is one of the most basic measures, how it's measured and processed by seadas has changed the least in the past decade, and therefore it's the most consistent and extensive collection I have. (Also note: out_track is a seadas-specific function, not a general IDL function.)

Unfortunately, it turns out that IDL doesn't like looping through anything more than 32,000 times. And my blotch of coordinates contains 125,557 points (that's 125,557 square kilometers in the SAB). I saw suggestions to use "for ctr = 0L" instead of "for ctr = 0", and "fnames[ctr]" instead of "fnames(ctr)", but in the end, I used Matlab to break up the file into four parts:

blotch1 = polishedblotch(1:32000,:);
blotch2 = polishedblotch(32001:64000,:);
blotch3 = polishedblotch(64001:96000,:);
blotch4 = polishedblotch(96001:end,:);

fid2 = fopen('polishedblotch4.dat','w');
for i=1:length(blotch4)
fprintf(fid2, '%6.3f ',blotch4(i,1));
fprintf(fid2, '%6.3f ',blotch4(i,2));
fprintf(fid2, '%6.3f\n',blotch4(i,3));
end
fclose(fid2);

and added some more lines to the IDL script:

out_track, iband=1, ifile = 'polishedblotch2.dat', ofile = STRMID(fnames(ctr), 75, 8) + 'blotch_chl.txt', /no_connect, /append & $
out_track, iband=1, ifile = 'polishedblotch3.dat', ofile = STRMID(fnames(ctr), 75, 8) + 'blotch_chl.txt', /no_connect, /append & $
out_track, iband=1, ifile = 'polishedblotch4.dat', ofile = STRMID(fnames(ctr), 75, 8) + 'blotch_chl.txt', /no_connect, /append & $

... which amounted to the same thing.

3. Putting the data into the database

Now I had a bunch of coordinate points, and I had used it to extract some data. It was time to put all this into my PostgreSQL database!

Why would I want to do that, you ask? Why not just open it in Matlab again and do some simple division? Well, that would work great if all I had to do was a few images, this was the only time I'd have to do it, and then I'd never hear about this particular task again. However, if I'll eventually end up having to do several thousand of them spread throughout the decade, the excessive paperwork would eventually kill me.

It had also occurred to me that, as long as I'm extracting all this data to calculate percent cloud cover, why not save it somewhere easily accessible where I can use the data as actual data, too?

So I made a couple new tables. Blotchcoords would hold all the coordinate points, and then blotchdata would refer to it (plus several other tables I already had) and contain the actual data. And I wrote some PHP to get it all in. Most of it was to turn seadas's bizarre output format into something that the database could understand. First, to fill blotchcoords:

$counter = 0;
$success = 0;
while($datablock = fgets($file_handle)){
$counter++;
if (substr($datablock, 7, 5) == '( 1)') {
$lat = substr($datablock, 32, 6);
$lon = substr($datablock, 42, 7);
$value = substr($datablock, -21, 8);
$query = "insert into blotchcoords (coords_id, latitude, longitude, depth) values (nextval('blotchcoords_coords_id_seq'), $lat, $lon, $value)";
if (pg_query($dbconn, $query)) {$success++;}
} #endif
} #endwhile
echo "$counter lines processed, $success lines entered, for $file.\n\n";

It turns out that 125,557 database inserts takes a few hours. While I was waiting, I wrote the additions to put the actual data in; it's basically the same, except that the script first has to find the right reference in the coordinate table before doing the database insert.

$findcoord = "select coords_id from blotchcoords where latitude = $lat and longitude = $lon";
$out1=pg_query($dbconn, $findcoord);
$coords = pg_fetch_object($out1,0);
$query = "insert into blotchdata (blotch_id, value, date_id, prod_id, sat_id, coords_id) values (nextval('blotchdata_blotch_id_seq'), $value, $date->date_id, $prod, $sat, $coords->coords_id)";

It turns out that 125,557 reference lookups in addition to database inserts takes 12 hours. o.O I've since written up a shortcut; instead of looking up the references, now it just assumes that the coordinates are in the same order as the data, and counts up accordingly. Which is generally bad practice - never assume anything, ever - but in my case the coordinates data all went in in one go without stopping, so I'm pretty safe.

4. Calculate percent cloud cover

And finally, I could do the actual calculation! Here it is in SQL:

select ((select count(*)::numeric from blotchdata where value = -1 and date_id = 2314)/(select count(*)::numeric from blotchdata where date_id = 2314))*100 AS percentcloudcover;

(In the case of chlorophyll, clouds are -1.)

It turns out that for May 9, 2009 (top left), cloud cover was 5%, and for May 10, 2009 (top right) it was 35%.

:D

THE END

In the end, I've managed to use bits of every coding language I know at some point during the past week - and was comfy moving back and forth between them. And knew how to do the whole thing without asking for help from anyone (except for a bit at the end there to tweak the SQL). For someone who has no formal training in any of this stuff, and who was completely clueless six years ago, I think I'm doing pretty good. :)

24 May 2009

Why I'm not smart enough to be a restauranteur

Food stamps can only be used to buy ingredients and raw food, not cooked food, and therefore can't be used in restaurants.

Some people with food stamps may not be able to cook food - e.g. broken stove, no stove, lack of electricity or gas to stove.

Seafood markets are primarily sellers of raw food. They therefore take food stamps.

Many seafood markets in the U.S. southeast will also prepare and cook food upon request. Officially this is a side service.

Some friends of mine (formerly the owners of a Chinese takeout) own and run a seafood market. It's located in a poor part of town. They will fry, steam, or boil nearly everything they sell (for a small fee).

The end result:

There is no actual difference between their seafood market and their Chinese takeout from an order-taking/food-passing perspective, except that nobody ever writes any of the orders down. T.T

There is a big difference at the cash register. Because food stamps can't be used for cooked food, the cooking fee must be charged separately as cash - which can get really complicated with the whole not writing anything down thing. But only to me, because everyone else there can do it in their heads. TT.TT

05 April 2009

Downsizing

Despite the low pay, the perks of working where I do largely outweigh the lack of money to do a lot of other things. Such as:

a) No dress code. I can wear whatever I want.
b) No set lunchtimes. I can eat whenever I want for as long as I want. (I prefer to just munch on things all day long while I work, instead of having an actual mealtime.)
c) No required clock-in/clock-out times. I can work whenever I want, so long as I do 40 hours' worth per week.
d) Full internet access. I can do whatever else I want at work, so long as I do 40 hours' worth of work per week. (We're not allowed to look at porn, and we'd get in serious trouble if caught, but it's not actually blocked (at least, not as far as I know. I've never checked).)
e) No restrictions on how we decorate our work areas. (Weaponry isn't permitted, but compared to tales I've heard of other places, that's minor - and doesn't really apply to me anyhow.)
f) Beautiful workplace. We're next to a river, surrounded by trees, and have our own nature trail.

My first office was in a large labspace at the far end of a building with no other offices near it, and I had it all to myself. I had multiple large windows with great views of the trees and river. I had full control of the thermostat, could play my music as loud as I wanted, and could eat whatever I wanted (e.g. Indian curry was not a problem). When I code, I tend to do a lot of pacing, muttering, and bouts of maniacal laughter - which was possible without bothering anyone else.

Then some drama happened with the owner of the lab, and my second office was in a cluster of other offices, and about a quarter the size of the first office. It had a single small window with a view of a parking lot and a brick building. It had thin walls, no thermostat control, and a tantrum-prone grad student across the hall who came in no more than twice a week on no predictable schedule and hated my music, my food, and the way I breathed.

Then some politics elsewhere shook out, and my third office is in the main building, is shared with someone else, and my part of it is half the size of my second office. I have no view of our small window because the other guy decided to take the half that includes it, and then he put up a bookshelf between us. Despite the lack of view and thermostat control, it's still a step up from Office #2 because the walls are thick, and everyone around me is on a predictable schedule - I can plan food, music, and the bulk of coding accordingly.

Last week I got an email about how my phoneline has been scheduled to transfer to a "workstation" in our new, almost-finished building. My fourth office will be a cubicle in a large, central plaza, with about half the space of my current office.

I'm wondering if I can beg my way back into my first office (the drama resolved while I was in the process of moving out, and then it was too late). If not, my new workschedule will resemble my current one, but the four days will be Sunday, Tuesday, Thursday, and Saturday - and on Tues/Thurs I'll probably just not arrive until 4:30pm.

If there's ever a fifth move, I'll probably have to request a red stapler.

11 October 2008

Open House 2008

Every year, the institute where I work has an Open House, wherein we let the general public mob the place. Allegedly they're there to learn what the institute does to deserve taxpayer money, and maybe some basic marine science too. In practice it's more a place for small children to get their faces painted and do crafts and run races and play inside a giant inflatable whale. We have a jazz band, and in some years people walking around in costumes of marine creatures (and from Spongebob Squarepants).

Even so, every year we try. This year I made a poster:


(click to read)

It was as dumbed down as I could get away with. The institute faculty don't seem to know how to explain things to the average carnival-minded layperson of casual non-interest, and the other posters were pretty technical. Mine had people standing in front of it longer than the others, so I call it a success. :)

29 September 2008

Followups

1. The empty restaurant building across the street from me now has a sign that says:
Coming Soon
Cajun Grill Cafe
Bourbon Chicken !!

So. More chicken then. But at least it's not the battered and deep-fried kind, like the last two places (that failed there). If it's anything like the one at the mall food court, I'll probably eat there regularly. If not, well, I hope it will serve actual Cajun food, which the mall food court doesn't.

2. I stopped using the shoe lift.

You know how when one of your joints needs to be cracked, it feels sort of itchy and naggy (and eventually stabby) until you crack it? Well, that's what happens to an undefinable spot in the back left of my skull after a few weeks of shoe lifting. The chiropractor couldn't reach it. The backup chiropractor couldn't either. It takes weeks after I stop shoe lifting to work out on its own.

I think I'll save the shoe lift for times when I'm doing lots of touristing.

3. She is a dear, sweet little old lady. She was retired and gone, but says she found it not to her liking. Now she's unretired and back, and watching over us all once more.

4. Good things that have ended sometimes have epilogues and sequels.

Business at their wholesale seafood market is slow but growing steadily. The bun that came in February is now in China. The bun's brother, who was in China, is now here. A few of the original takeout customers have indeed found their way there. And apparently my Mandarin has improved due to those eight months of being unable to communicate with the new takeout staff otherwise.

5. The traffic light that hates me still hates me. For a while I was driving through the shopping center to go through the crosslight without having to make a U-turn. Then for a while it looked like it had changed its ways - so I lost the habit of driving through the shopping center. But it was all just a clever ploy! Now, this past week, it's back to the same inappropriate redness as before. T.T

6. Last year I was paid to skulk around a dormful of sleeping children. Last week they paid me to do it again. Next year I'm penciled in to do it a third time. Who says peace of mind is priceless?

7. Not only can I touch my toes without warming up, after today's yoga class I could touch my thumbs to the floor! Yay progress! :)

10 September 2008

My Office

While I was taking keyboard pictures yesterday, I also took some of my office. Here's what my desk area looks like:


04 September 2008

Deep End Geometry Revisited

(Note to Nathan: It's math again, but this time with no numbers at all! Only pictures! If it still doesn't make sense, well, the pictures are pretty....)


This is the type of picture I've been making for the past three weeks. That rainbow blob thing in the middle is made up of several thousand dots1. Wouldn't it be nice if I could stretch them out to fill the whole box instead of having them all jammed together in the middle?


Here's the direction I want to stretch them. The one on the right is a bird's eye view of the same thing. Unfortunately, I can't stretch them out that way. I can only stretch them in one of these ways:


Obviously, then, I should move the blob until it's pointing in a better direction. To be able to stretch them the way I want, it needs to be pointed like so:

See how easy that was in Photostudio? Unfortunately, it doesn't work like that when it's a bunch of dots on a grid. To do what I want, I need to either move the grid around to match the blob, or move the blob around to match the grid.

Lots of people made lots of suggestions, all of which had strange side effects, so in the end, I didn't end up using any of them. See, it turns out that although it's hard to rotate a blob of dots when you have them in a box, it's not at all hard when you've got them on a circle2. In fact, it's ridiculously easy.


Yep. That's what I call thinking outside the box. :) And it allows me to do this:




Footnotes for the advanced class:

1. 79,744 total data points. Which needed to be rotated 55 degrees counterclockwise.

2. Cartesian coordinates are X, Y, Z. Polar coordinates are directions with magnitudes (or angles with radii) (or, in 3D, it's azimuth and elevation to go with the radii). Rotating in polar is easy because all you do is add to the angle. So I converted from cartesian to polar, did some addition, and then converted from polar back to cartesian. Voila!

26 August 2008

Some Easy Arithmetic

Today I made graphs. Lots of graphs.

The goal was to make a two-month time series. I picked out 19 days. The figure for each day had four panels. Each panel had two lines. Each line had 110-190 dots.

So, that's 19 figures. 76 total panels. 152 total lines. 9,348 total dots.

Predictably, the first one was insanely difficult and took 5-6 hours. (Arrr Matlab.) After that, I had a script. The other 75 took maybe 20 total minutes (interspersed over a bunch of blog reading... >.>). Yay Matlab. :p

Printing involved some voodoo (is there any other software out there where, if something fails to work the first time you do it, it inexplicably works fine when you do it a second time? even if you change absolutely nothing in between?), but fortunately it didn't involve sacrificing any goats like the last time I had to work with YY-plots.

Tomorrow? I get to do it all over again with the same 9,348 dots - only this time, I'll be doing it in 3D.

16 August 2008

Going off the deep end with geometry

[Warning to Nathan: Lots of math is about to ensue. You might want to cover your eyes...]

Yesterday it took me all night to learn that single precision numbers and double precision numbers are not at all the same thing. Not that Matlab will tell you this, of course. They'll look exactly the same to the untrained eye. No, you have to specifically ask, using an obscure function such as superiorfloat(). All Matlab will do is inexplicably refuse to make straightforward plots of those numbers until after you change them.

Today I learned that it's quite difficult to rotate the axes of a cartesian system to anything other than 90 degrees, especially if you've never learned any math past calculus (and you didn't do so good in calculus).

There's:
origin=newpole(polelat, polelon);
[lat_rotate,lon_rotate] = rotatem(lat, lon, origin, 'forward', 'degrees');

... which will indeed do some rotating of the data. However, the end result won't bear much resemblance to what you had at the start.

Then (via John) there's:
xdist = sqrt(((m*lat - m*b) ./ (1 + m^2)).^2 + (((1-m^2)*lat - b + b*m^2 + m*lon) ./ (1 + m^2)).^2);
or
xdist = sqrt((((lon + m*lat + m*b) / (m + 1/m)) + b - lat).^2 + (((lon/m + lat + b) / (m + 1/m)) - lon).^2);

... which uses linear algebra and vectors and dot products and all sorts of stuff that go completely over my head. I have no clue how the equations got derived, only that they don't seem to do what I want them to, and I don't know how to fix them. Also it occurred to me while I was fiddling with them that they'll only give me the x values, not the y values...

Snave tells me it's simple. Those matrices look scary to me. o.O

On Monday I'll reveal my utter ignorance to the local Matlab expert, and maybe she'll figure out how to do all this for me. Either that or I'll abandon this foray and go to Plan B (which is to do what my boss actually asked for as opposed to what he wants (and will probably be asking for when he finds out that what he asked for won't be sufficient)).

26 June 2008

Workweek Nirvana

The traditional 40-hour workweek calls for 8 hours of work per day for five days - Mondays through Fridays.

I've heard that some Corporate Cubicle Land type places have started offering workweeks that allow three-day weekends every other week. It calls for 9 hours of work on Mondays through Thursdays, then 8 hours or 0 hours on alternating Fridays.

Then there's my plan. 10 hours per day on Monday, Tuesday, Thursday, and Friday. Wednesdays off. It doesn't sound all that palatable at first glance, especially to those accustomed to the traditional five day workweek, because who wants to work 10 hours per day when 8 hours is already too long?

But it's not like that at all. First, it actually isn't a five-day workweek. It's 2 two-day workweeks with two "weekends." What that means is, I don't suffer the weekly mini-burnout encapsulated by the "Thank God It's Friday!" concept. At all. There's no time for it to set in because each workweek is over after two days. Those two extra hours per day aren't even noticeable.

Aside from the mental breaks, I'm also not trying to figure out how to cram odd errands around town into the beginnings and ends (and in many peoples' cases lunches) of the workdays. Those errands happen because many places aren't open on weekends, which means they must be done during a workday - but I don't have that problem because I have a full day to take care of them all at once on Wednesdays.

In short, I get a LOT more work done while I'm at work because I'm focused on work. I'm not distracted by other things I need to do, and my mind stays well-rested. My employers get more bang for their buck. Everybody wins. :)

17 April 2008

Some Observations on the Nature of Coding

Never explain the details of any coding problem to a True Coder. Their eyes will light up, their brain will start working out how to solve it, and next thing you know they've taken over doing the whole thing. Then things get all awkward if you don't actually use their solution, because all you were doing was thinking out loud or seeking some sympathy. It's better to just not even mention it (or, if they're helping with part of a larger problem, that the larger problem exists).

Never explain the details of any coding problem to a non-coder either. Their eyes will glaze over and they'll start looking for escape routes. Or they'll feel all helpless that they have no idea how to help you with what is obviously an exceptionally upsetting tribulation.

In short, coding woes are meant to be suffered alone*. As are coding triumphs meant to be enjoyed alone, because without any commiseration during the woe suffering, the triumphs won't make much sense to the outside observer. Coding is fundamentally a solitary pursuit.


*unless you're stuck in an IRC channel with me. In which case you might be subjected to random outbursts of High Geek that make no sense....