Categories
Computers Lab Programming

OSLO is a strange one

Experimental physicists have to be the jack-of-all-trades, even on a good day, but building a new laboratory, on a budget (for any definition of “budget”) and with a limited team, is an exercise that would test anyone.

For my field, atomic physics, one needs a lot of different expertise: vacuum systems, computers, electronics, machining, optics are among the ones first to my mind. Today I’m looking at one of the tools that we are using for the last topics: optics.

In some ways, optics is pretty straightforward (both geometrical and diffraction optics), many of the calculations one could write in Python/Numpy just as well, as any software can do it. They are just pretty tedious, and there are a lot of them, optics is not a new profession. Some optics design software is very useful then, and there are not that many of them, lots of work goes into the ones that exist, thus they can be extremely expensive. One of the industry standard seem to be Zemax, and many lens manufacturers provide the specs of their lenses in a Zemax format – though it is fortunately just a relatively simple text file. On the other hand, its cheapest edition is $2500, and goes up to $9500…

Another serious competitor is OSLO (Optics Software for Layout and Optimization) which is still very well known, and fortunately for us, has a dumbed down (limited number of surfaces, not all the functions available), EDU version, for free. It even runs on Linux with Wine.

I instinctively resist any software in science & research that is not free & open source, because I feel that it closes some people out, though had to use something, and in the meantime I have grown to OSLO quite a bit.

OSLO ray graph of an imaging system
One of our imaging system design

Using OSLO, I have found that one big advantage of these software is their catalog: the glasses (oh-very-important for optics) and stock optics of different companies. This alone makes everything much easier.

What does the lens designer software do? You enter the parameters of some lenses by defining different surfaces and materials & distances between those surfaces, give it some lightbeams, and see what comes out of it. Most of this happens in this window:

The window to enter the system parameters
Lens spreadsheet

After these settings, one can run a number of different analytics code, checking the performance and behaviour of the system by calculating a bunch of physics parameters, or can modify the system to optimize that performance one way or another.

This is where the number 1 strangeness – and big bonus – comes in: OSLO can be scripted in a language called Compiled Command Language (CCL), which is a subset of C; and not just scripted, but the whole program is written on top of the CCL compiler (as I understand)! The result of this is that:

  • Your scripting can be just as powerful as the entire program, since both sides have the same functions accessible
  • There are a bunch of scripts included in the main version and even if CCL itself feels poorly documented, there are plenty of examples to learn from
  • Once your script is compiled for OSLO, it can be totally part of the system, your own menuitems, options, defaults, everything
  • Scripting is not just bolted on later, but the whole software feels like a result of “eating your own dogfood“, resulting in a much better experience.

Optics design is tedious, so once I figured out how to do the scripting, everything just become nicer. Haven’t had time to do a lot of things, but the script I have so far is open source, and hope to add other things later.

From the programming point of view, there’s one more strangeness. Starts with that the output of numerical calculations looks like this:

Window showing numerical results of a lens' calculation
Looking at some numerical results

Those are all results from different functions, calculating spot sizes and wavefront distortions and what not, and those can be run from your own script – but the return variables are just printed. And they are a table. Those are table values that have to be accessed, so for example if I want to have the Strehl Ratio there, I would have to assign the value of something like “c1” to my internal variable – c for 3rd column, 1 for first row. Though to be this simple my code would have to clear the existing table before running the wavefront function correctly. This results in a lot of counting on the screen to see what row/column output of a function I want to actually use.

Internally, I think most of the calculations are following a finite number of rays. Finite but very high (~1000). The big problem, that could get the unsuspecting people (like I was), that what looks like a continuous calculation, is actually digital. For example if I set an aperture within the system that cuts into the incoming rays, and keep changing the aperture size (which is just a real number), the output results don’t really change unless I exclude or include some of the beams that OSLO is using for calculation – thus the result is changing in steps, and hard to trust. I guess there should be a setting somewhere to change the number of rays used, but still trying to find it.

It is one clever program though. The input and output parameters of a lightbeam are really connected by the system, since practically speaking, the optics are just transforming some parameters of the beam into other values, thus if I set the input parameters, the output is given. With OSLO they do this in a way, that the code just follows what parameters you have changed last time (input beam size? output image angles?…) and that will be a fixed variable, while everything else is adjusted. Some parameters disappear when others take certain values (set your object very far away? then we don’t have to let you set your object size, since it’s not important, instead give you a viewfield angle). It’s funky when I figured it out, but took a while…

I don’t know how much longer I’ll have to use it at work, but this looks something that really tickled my interest learning optical design much more, and once I have the hang of the quirks, it’s pretty neat. If anyone’s interested, there’s a pretty useful mailing list.

Now if only there was an open source solution… : )  (please drop me a line if there’s a good one)

Categories
Startups Thinking

Academia is failing but not for everyone

Recently I have some mounting problems and stress at work, and while it would be easy to write it off as unfortunate circumstances, I felt like I need to dig into the causes much more to understand and try to fix them. It seems that it’s not just me having problems, my entire “industry”, the Academia has some fundamental difficulties. Can hardly say things about other fiends, but I have some overview of the atomic physics research done around the world, and nothing indicates that the issues are confined to physics alone. These are the problems I try to explore here.

I’m a physicist, working still as such, in my 5th year as a post-doctoral researcher (this is my second post-doc position). Altogether I think I am in physics for about 14 years now (or 20 if we count the high school where I was already conquered by it, just wasn’t quite aware of it yet).

Usual lab scene
In the lab

At my lab I felt there are some things that could be done better, to have a better group and research quality. I tried to bring some ideas from my old lab, from the startup world, from computer science, and my ideas what research should be like. Most of those changes were shot down, and many of the changes experienced became very frustrating, I felt like I’m on the wrong track.

Recently I got to read Peopleware: Productive Projects and Teams, and while it is aimed mostly at the IT industry, plenty of things are completely general. It was one of those reads that I was on the verge of tears in the end, because recognized so many things that went wrong in my environment.

One of the most important thing I felt was that our lab should be a team, a consciously cultivated team to really achieve its potential. The upper level always indicated that they took the fact that we work in the same lab as a sign that we already have a team, and that’s just one of the problems.

From the book it feels that the entire success or failure of projects mostly depends on the people and their connection with each other. Looking at the Academia, it feels like almost everything is set against building a great team. Not consciously, many people have lofty goals of efficiency, productivity, and similar things, but they go around naively to achieve those, and in the same time they destroy the resources that would create efficiency and productivity and creativity.

Looking at Peopleware’s Chapter 20 about Teamicide, they list a number of things that inhibit team formation or crush working teams:

  • defensive management
  • bureaucracy
  • physical separation
  • fragmentation of people’s time
  • quality reduction of the product
  • phony deadlines
  • clique control

I have experienced pretty much all of this in the labs here. Defensive management, people cannot be trusted to make the right decisions, because it reflects bad on you, so you have to make the choices for them and push it through, generally thinking that the people you got for the job are actually incapable of doing it. Bureaucratic, have plenty of stories about that, everyone has, even worse in Taiwan than general. Physical separation is less of an issue here, we are all in the same office. Fragmentation of people’s time, even when working on apparently “priority project that you need to drop everything else until it’s done”, it’s still “hope in the same time you can help out with X & Y”. Quality reduction, this is the worst one for people who believe in their abilities, having to work on something that I know it would be worse by far than other solutions I could bring, but it’s squarely ruled out, and now I’m feeling I’m spending my time building essentially waste. Phony deadlines, there are plenty of them, because people think that setting a deadline will make people work harder, which is missing the point – the hardest workers are those who are not pressured and have been given worthwhile goals”. Clique control, stopping efforts that would mainly be about knowing each other, effortless communication, and feeling that we work “together” instead of “in the same space”.

In later chapters they also point out a few more parts. High turnover poisons everything. Management don’t invest in training, people are not invested in their work, it’s just something “temporary”, why to give it all the effort (consciously or subconsciously)? Academia is almost designed for high turnover. Masters students for 6 months to 2 years max. PhD students from 3-8 years (though the long time is more problematic in terms of exploitation), postdocs from 1-2 years, and you are expected to move on and move up. Become a professor “somewhere else”, and start your own high turnover lab. The whole thing is quite often just milking the current place for results, or milking the new workers for their energy until they leave, because they are known to be leaving soon.

This also gives rise to thinking of people as building blocks. How often it is heard that “I need more masters students to do this project”, or “you should hire a post-doc for that”. Not ability, but function.

There’s often very little training about generally useful things, because of the high turnover is so etched into people’s mind: if my student will leave soon anyways, why teach him, or why teach the group in general something that is not immediately useful for their work? Why waste time with that?

There are lot of other problems as well, which mainly comes from how people get their jobs. To run a research group and become a professor, one needs to have: academic skills, teaching skills, management skills.

The first one people demonstrate through papers, passing exams and so on, so usually they have indeed good skills (don’t want to dispute that). The other two skills are on the other hand never tested, and just taken for granted, taken as the “easy” part. On the contrary, most people who think they can manage people (me included), are naive and make a lot of mistakes, even be completely counterproductive. Many professors are terrible teachers and managers, while they think they are doing okay or even great, so they don’t have to examine their level, nor improve on it.

Because of these things, that are so ingrained into the Academia, I’m even surprised that there’s so much success as there is. I would argue, many times the success is temporary and because of people’s skills to persevere against the odds. In some subset, actually, things fall into place. In my previous research group at Oxford, things were like that: professors let students to experiment and try things even if they don’t agree or see the point at the time (within limits, of course), people stayed on after their PhD, or spent their masters there as well, so much lower turnover, they took the bureaucracy out of the picture so if I needed something I just had it, no overtime because everyone knew that people need a life (and dinner at college starts at 5:30, so got to leave before that), and natural team building, like the tradition of whole departmental coffee (morning) & tea break (afternoon). We talked about everything, got to know each other, exchanged ideas, never got stuck in our work. And everyone was happy. I think I got spoiled by that, and took such environment for granted.

Of course, most of the things I mention here are not new nor original observation. To understand the situation, I started to read some books that supposed to guide new professors, for example New Faculty: A Practical Guide For Academic Beginners. I was wildly agreeing with the picture they paint of the problems in the preface, and starting to see some of the things a little better, while it still feels as if it falls short: most people trying to fix the problems by better assimilating themselves into the existing community, instead of shaking up the way “things are done here”.

That’s not necessarily bad, as another book I got recommended, the Orbiting the Giant Hairball showed me. There are a lot of resources that even a troublesome environment can provide. Still, how much one’s energy should be invested into fighting the system, and how much into the things we want to do to change the world?

Crossover Labs

Looking at the whole situation, my last 5 years were good lesson in life, while they left me almost nothing to go ahead in Academia. Joined labs that were stuck, or still building up, so I learned a lot, but haven’t got anything published, which is almost the single thing they need in the Taiwanese system to enter the professor level. Also, as I mentioned, most of the problems seems to be by design, so it feels I can do relatively little from the inside, if I want to change things. And I really do want.

I don’t want to leave physics behind either, research is what I’d like to do.

Instead, let’s think of something crazy: there were really successful non-academic research laboratories, let’s take Bell Labs. Unfortunately they have stopped fundamental physics research, but what if that tradition would be revived? If Bell Labs needed a powerful mother company to run it, how would we do a similar thing “21st Century Style”? Can we get some inspiration by non-conventional research and technology, learn from the old Bell, from SpaceX, from the HP garage, from the MIT Media Lab, from firms like IDEO, from Formula 1 teams, from Japanese innovation at Honda/Toyota/others, from IBM, from Sparkfun? These are all a bit wild examples, while I believe all of them have some insight that will or have changed me for the better.

Can I find a place where I can test my theories of research, how the 20% time would work in a lab; finish side projects that are right now dissuaded and covered up with just throwing grant money on it; see how people would probe the universe without the pressure to publish or perish; when people can change fields and become useful in research in a way they find fitting as well; when learning and training are priorities; when the quality of results is not been sacrificed…

I kinda think that I could do this in one obvious, but very scary way: I’d have to start it myself.

Thus it seems the path forward is taking my time at the current position till the contract runs out at the end of this year. Learn as much as I can. Do things as well as I can. Than based on all those experience, found a new laboratory, let’s give it a working title of Crossover Labs, and see what can be done on a shoestring.

Set up a laboratory that puts research first, based on the people. Make it so that it can fund itself from its byproducts in good Cambridge style where successful research is spin off into companies. Let’s have a place which doesn’t have to push people to do things, because they want to do, just get out of the way of them kicking ass. How to do this will need a lot more thinking and will definitely write about it more.

It is easier to say than to do, so if this vision is something that resonates with you as well, then let me know, that would be already helpful!

And I’m a bit sad that I got to the stage of “calling in well”, but it feels it has to be done:

Chances are you’ve heard of people calling in sick. You may have called in sick a few times yourself. But have you ever thought of calling in well?

It’d go like this: You’d get the boss on the line and say, “Listen, I’ve been sick ever since I started working here, but today I’m well and I won’t be in anymore.”

– Tim Robbins: Even Cowgirls Get The Blues (via Peopleware)

 Thanks David and Nathan for feedback before the publication of this post.

Categories
Admin

Fighting forum spam

As one of the managers of Ignite Taipei, I’m trying to come up with new ways to let the community communicate, new ways to share information, advice and all. A while ago I have set up a forum at http://bbs.ignitetaipei.tw/ and I thought that will be an interesting experiment. Well, so far it is useless for communication, but turned out to be a very interesting experience from the sysadmin point of view.

I used FluxBB, because it looked simple enough, seemed to be quite fast (for low traffic volume at least), and well configurable. Except that within a very short time I run into a spam problem, so many fake users registered, and lots of algorithmically generated garbage text with a bit of advertisement here and there.

First I looked into FluxBB’s own solutions, and looks like it might not have been a great choice, because many of the spam-fighting plugins are out of date, or not supported anymore, or just a real pain to set up. The immediate practical step I could take was updating my security questions, roll my own version of “written with words, how much is 5 + 4?”, the regular low-tech captcha on FluxBB. Looks like the original answers are already in the database everywhere, so had to write my own set, which seemed to work for a while, cutting down on red-flagged registrations. But it’s not ideal, since I want to make this a dual-language forum (Ignite Taipei has both English & Chinese as official language).

Instead I turned on email confirmation. When someone registers, the password is sent to their email and have to use that to sign in. It was okay for a tiny bit, then crazy registration boom happened. I think I might be the only one real member of the board (I said that it is a failure so far for communication:) and there are 500 other spam members. Looking at their email addresses, it seems all of them have Hotmail. That kinda suggests a giant failure at Hotmail to restrict automatic registration, which is probably a problem overall. I cannot just throw out Hotmail addresses either, because it’s a popular mail provider here in Taiwan too (my first email was Hotmail too, but that was a looooong time ago, before it was Microsoft property).

So captcha don’t work, email don’t work. What to do instead? At the time I was playing around with Cloudflare, to act as an easy to use CDN. I tried it before for our Ignite Taipei blog, which is hosted on Tumblr, and that doesn’t play well with Cloudflare unfortunately. Couldn’t use it for this blog before because of my DNS provider, but now I switched, so started playing with it again.

The dashboard of the Cloudflare interface
Cloudflare stats snapshot (parts of it)

Instead of enabling Cloudlfare for the entire ignitetaipei.tw domain, just turned it on for the forum, since it’s hosted elsewhere. And that totally did it. Spam stopped that very moment, and haven’t returned since. I think what happens is that Cloudflare knows globally a lot of web/forum/email span hosts, and can challenge them or generally ignore them. Can even see where those spammers are coming from.

List of captured threats on the Cloudflare threats console
Cloudflare Threats Console

One weird (but actually not that surprising) thing is that the most active web crawler on the site (Cloudflare gives that info as well) was Baidu by far, so I guess more people knew about the site in China than elsewhere. Why’s that? Some forums that share vulnerable sites, or something like that? I barely had any Chinese content at that time, so it cannot be that. And since I turned on the threat control part, Baidu seem to have dropped quite a bit (submitted the site to Google so now that’s the busiest crawler).

All in all, Cloudflare is an interesting experiment. I can really mess up my DNS with it, and could blocked my own site for several hours, but in general it worth it. Just have to be careful. For example when testing, use their own name servers to check the information, and maybe instead if “automatic” time-to-live, set some very short time first. I usually use Google’s 8.8.8.8, and they pick up the first wrong setting really quickly, then it takes hours to pick up the correction I made just minutes after the first one.

After a bit of playing around, at least I have no spam anymore (keep fingers crossed). Now just have to get people to use the forums. :)

Categories
Computers

Editing talk videos for Ignite Taipei

As an organizer for Ignite Taipei, there are plenty of technical things that I need to take care of. Managing people’s slides (plenty of fun there), runing the presentations (it needs the Ignite type 15s autoadvance), setting up web stream (where everything can go wrong), recording the talks themselves. One thing I haven’t done yet, is editing the videos.

For all previous events we got some more experienced people to help out. The results were okay, nothing surprisingly great but plenty usable. It still did take a lot of time to do that, and I don’t like to ask people favours. Instead this time, for Ignite Taipei #7, after almost a month of procrastination I decided to do it myself. Ignite is an experimental ground for me, where I try a lot of things I think about startups (even if it is a non-profit organization, it can have a startup like “organization”), and I thought if I was a CEO I would make it such that “the buck stops” really here with me. Have to experience the work myself to be able to find better people doing it later. And I like video editing (from the good-old DVD ripping days, that came really handy this time as well).

Recording

The recording was done with my Canon EOS550D. When I got the camera, I could have gotten a 600D, but I thought “I won’t be using this for videos!” Duh! Now I have to put up with freaking large files, because 550D cannot compress them on the fly. Also, need to check whether I can get better SD cards, because at 1080p it broke the recording last time (that’s why the Ignite #6 videos are still not edited). 720p (at 50fps) seemed to work somehow, and looks good too. Will try to fix that still in the future. Now I have a GoPro Hero3, that  can do 1080p without even breaking sweat, and I plan to use that one for the next Ignite.

Title screen

A video starts with good title screen. Previous editors could manage animations and all the works, which I didn’t have any idea how to do this time, so just keep it simple: a static page. But still have to add my own spice: not just a simple title and header, but something good-looking, and expressing the spirit of our organization. So got a cool HDR photo of Taipei City (well, actually Zhonghe, the suburbs to the south) from my friend, Chia-Da Hsu, tuned it a bit to be a background image, and plugged it into Inkscape.

Editing window of Inkscape
Creating the video titles in Inkscape

I like Inkscape a lot, open source, capable, fun.

Put in the background, position the text. The font used by Ignite, and thus for most of our own text is Insignia LT. To make it more readable (20% gray setting), make a black outline to the text: Copy/Paste in Place/Stroke paint to black/Make it thick (20px thickness for us), and blur with a suitable parameter value (was 2 for us), then move the layer one below. Voila, outlined text, drapper. Just had to make one, then replace the text (and recreate the outline).

Editing

I needed to put together the video with the slides, side by side, with synchronized timing, so it would look similar to the original talk. First, I needed to get the slides in image format, that I keep doing with ImageMagick, whit this script:

Unfortunately, the ImageMagick on my ArchLinux seem to be chocking on this script, that used to work so well 6 months ago. Looks like it outputs only the first slide. I had another computer with an older version of ImageMagick and it worked like a charm. Got to investigate it – or wait until the next Ignite and hope the problem goes away.

Next I had to find a suitable software for editing. As much as I looked, Linux didn’t have many good ones, or even many of any kind. Avidemux don’t like MP4, and it has bitten me in the butt before, Cinelerra didn’t work for some other reason, and these are the two in the official ArchLinux repo that I could find. Had to look more to get to Flowblade, an editor written in Python. I got to say, it’s such an amazing bugfest, that it drove me nuts sometimes, but got the work done, and that’s more than I can say about the rest of the candidates.

Combining the video on one channel, and the slide images on the other channel, translation to move them side by side, then finally a blending compositor so that the layers don’t overlap.

Flowblade window during editing
Combining the video and slides in Flowblade

Looks quite good, was a rocky start to figure out how it went, but when it went well, then I got one talk done in about 10 minutes, which is great! It helps that the Ignite format is predictable (15s each, could just add an image, and found the new insertion point for the next one in a very short time. Though now I see that Acrobat Reader that I use to display the slides, don’t do accurate timing usually.

Then it came the rendering. Originally I used a pre-compressed version of the videos (from 2Gb for 5 minutes to about 200MB), but the quality just wasn’t that good after the joint rendering. Went back to the original source, and tweaked the parameters. In the end, discarded the entire stock parameter setting, and used these ones manually. To get a good result, the important ones are preset (from ultrafast to veryslow, increasing quality) and crf (lower number means better quality, 18 is good, 17 a bit overkill because I like that, about 20% larger file than 18):

Too bad that Flowblade cannot do 2-pass encoding, maybe can do that another time differently, for better quality and smaller filesize. Also, had to make sure that I marked the beginning and the end of the video well and just rendered that part, otherwise it crashed right at the end of the job. Not good, considering that it took about 40 minutes each to be done.

Flowblade is unfortunately using absolute paths to remember things, and cannot edit the settings very easily, so couldn’t move the rendering onto a more powerful machine. Maybe could make a tool for save-file conversion, it’s all Python anyways…

When that done, I remembered from listening to a lot of Youtube videos, that the sound had something to desire, and all I had was puny DSLR microphone recording, so I run it through a normalization to tweak the level of the audio.

Upload

Time to upload to Youtube. Fortunately the network is great here in Taiwan, so it was a very short time, sometimes the postprocessing took longer than the actual upload.

The Youtube video info editing window
Editing all the options for the uploaded video on Youtube

From the settings I always go for Creative Commons, not that anyone had remixed our videos yet. Also set some tags, maybe that can improve our visibility in search, as well as the recording date and location. The description writing is tricky. Most of our videos are found through recommendation on the Youtube website, so it should be good. I wonder what would make it work better?

Ready to share

All that done, just created a playlist to tie the videos together, and found this new (to me at least) look, which is not too bad:

Youtube playlist window with all the uploaded videos
Finally, got the playlist ready

Now, after 2 days we have over 200 views, which is not bad considering that I could barely advertise yet, only friends sharing on Facebook and such (and you know how Facebook hides everyone’s precious updates, so it’s a surprise we even have this many).

Finally, the results can be all enjoyed.