Sunday, August 05, 2012

What if Humans had Infrared (heat) Vision ?


Evolution has made humans the most advanced species on earth and as of now on the solar system. We are the most intelligent of all creatures. We can walk on two legs and can handle objects with great dexterity, have a vivid imagination and are creative. All these have been possible because of a whole lot of ifs and buts. We are here because of a whole lot of right conditions in the equation of life. The right temperature, the right combination of gases, water, the right chemicals.

There is one aspect of this evolution that many of us don't think of much. VISION. More accurate description would be color vision. Not all animals have evolved to be capable of perceiving the wide range of colors that we perceive today. We can appreciate red, green and blue today. The females are more evolved to see them as cherry red, bottle green and peacock blue. Did you know that humans make out color with 3 receptors . Some birds have 4 . And some invertebrates have up to 10 receptors . They can see more shades of color than we can imagine.

The reason we are able to do this is because we adapted to perceive the most common range of wavelengths on earth. The earth's atmosphere locks out all the infrared and ultra violet rays from entering the atmosphere. So what enters earth and becomes the most common spectrum of light / electromagnetic wavelength is the visible spectrum, called so because we can see it. Over millions of years the creatures evolved and developed sensors that could perceive this spectrum .And slowly we could perceive a wide array of colors as well. Again , this is because of the factors were right.

WHAT IF HUMANS HAD INFRARED VISION.

Imagine a universe where we were on a planet that had more infrared radiation then any other wavelengths then it is possible that evolution would have taken a different turn.We could have developed infrared sensors or Pits . We would be seeing heat Signatures instead of color. The alien from the movie predator must have been from such a planet. It is a possibility. Aren't we a product of millions of years of evolution and adaptation to various conditions. It could be possible that we adapted to possess heat vision due to suitable conditions.If earth were to have a different composition of atmosphere, creatures could have evolved to have infrared receptors. Among all possibilities we could alter the current world in just one small possibility of humans possessing infrared vision, What would be different in such a world . The following passages are my thoughts on such a possibility.



Freaky chillout


Evolution and Physiology :

The evolution process of having infrared vision would mean that the creatures would have to be in an atmosphere that doesn't block infrared rays. Such a thinned down atmosphere would have high amounts of radiation, leading to a change in physiology. Infrared is attributed to heat. A cockroach like exoskeleton would help creatures endure such radiation. Skin and flesh around bone would make no sense when an exoskeleton can do a better job of preventing radiation. This also would mean that bipeds on such a planet would have soft gooey interiors.

Nocturnal behavior would also be something the bipeds will have in common with roaches. Vision being the main factor for this behavior. When you are seeing heat signatures, it would be so much easier to hunt at night when prey can be spotted by tracking heat emitted from their body. So man over a period of time would have adapted to being active at night. During the day, the sun would make sure every thing is heated up . If the eyes are sensitive , this would mean the eye would have trouble looking at objects during the day. It would be too bright ( or too hot ) for the IR eyes to comprehend. So man would be like an owl sleeping during the day and active during the night. a preference to the underground might be a possibility. Prehistoric men would have embraced caves as well as developed ways to dig underground caves like animals burrowing, before he could have come up with ways to build shelter. Many more creatures would take to burrowing as a way of survival and protection.
Another offset in the evolution would be in the composition of the exoskeleton. The exoskeleton might comprise of a combination of calcium but with a possibility it is re enforced with another metal. Vitamin-D and the sun are major contributors towards the strength of the bones. With a nocturnal behavior this is bound to evolve differently. Also, it would make sense for the exoskeleton to be made of better material than brittle calcium which is easy to break and not flexible.

Appearance :

I have strayed away a bit from the main focus, vision. Lets get back to vision. And when we think vision. We would be able to make out the outlines with the heat differences, but the sharp nature of our eye sight and our ability to see varying shades of light and shadows is lost. All flowers would seem to be blurry shapes of blue and red , different shapes , but blurry. A distinction without a difference .


Snake-o-vision
There would be other distinguishing features that humans would use for identification. We would be able to see the brightness in the brains due to the heat from the activity and differentiate people though the vein patterns and nasal passages and jaw bones. To an extent we should be able differentiate people based on jaw bones Structures and general features . These are dependent on the clarity of the such a infra red vision.

Races :

Distinction and similarity brings to my mind, races. Man has a tendency to find similarities between himself and others . This search for similarity is what brings together people as communities. This is also the nature that drives them to see people as different. In a world with no color ( as we know it ) , there won't be a chance for color discrimination. Would we have racism, or would every one be the since , we would all be blurry masses of heat ? There wont be a distinction of Caucasian , African or Asian. But man basic nature would have driven him to identify some similarities. It is possible that people with warmer tones of color find themselves similar. Since warmer usually means active people with a good metabolism. These might constitute what in such a world might be considered as superior. Ones with colder bodies might find themselves together . This would in terms mean a color discrimination in a world that sees heat levels.

There is flaw however in this line of thought. The flaw is the fact that the hot or cold bodies is not a genetic trait . If it is , then we would have such a divide. Fortunately that is not how it works. Family and origin could make it hard to differentiate oneself from another based on heat patterns if they are from the same family. So this differentiation would just exist as a way to categorize people (like thin vs fat ) and not as a means of differentiation( like black vs white ) that could lead to racism. It might be a world with just one kind of humans, blurry bright bipeds, a better world hopefully.

Beauty and Fashion :

What would constitute beauty on such a world . Features are not bound to be constant since your body's heat signature can change with varying conditions . What features would constitute sexy. Shape of your body still works so I guess that plays a key role. Apart from that , beauty could constitute the way our body tracts are aligned. An odd beauty might be people with a little misplaced heart or one that is more towards the center to contributes to a symmetry.

Dresses would be just be for practical reasons for such creatures. There is no point to fanciful colors when you can't see them. Comfort and use would take a precedence. It won't be awkward for your mom's to tell that you would have to change from briefs to boxers cause it would be in plain sight that your privates are heated up.

Colors and Meaning :

Violet to red would be the possibilities of how hot you want your soup not possible fashion statements. You could see if the food is hot or not just by seeing it. He is so red right now , would be a common phrase depicting a person ill or working out. He is cool as blue would replace cool as a cucumber. Mood rings won’t sell that much , since that would be same as wearing a watch and carrying a cellphone.

Camouflage :

Camouflage for armed forces would not be as simple as wearing a dress with dirty patches of green. They would have to wear something sophistic that can hide their heat. A sniper would be better off firing from a fridge door than a window.



Chameleons and other creatures that use camouflage as a means of defense or offense, would have to evolve differently to have such a power. In order to be able to camouflage, they should have tremendous control over their body temperature.

Science and Medicine :

Medically and scientifically this vision would have proved to be a boon and a bane . We would be closer to understanding energy and its workings because heat being much closer of a definition to energy than light. Heat transfer and conversion of energy would be visible phenomenon. For example , as soon as some one eats food we can see the metabolism increase and understanding the heat generation. Lights on and lights off would be a good enough description for the alive and dead, for you can see life in active people and its absence in the dead. But medical studies would have developed different methods of diagnosis since some visual elements like pale skin, yellow eyes , red patches won't be available . Another aspect is that the clarity of identifying minuscule details .

Limitations :

The more I think about infrared vision, the more absurd it seems.

The basic problem with such a vision would be the range of vision. We will be limited by details that heat provides. Can we sense heat beyond a distance. Even though we can pick up heat signature by perceiving infrared signals, The IR receptors would have limitation to the amount of such signals it can process. If there are multiple layers of information, for e.g one person standing behind another, will we see just the person in front or both as a mixed signal ? Imagine the same across multiple objects ranging multiple distances . IR cameras can locate people movements inside buildings. If the eyes work the same way there might be too much information to process. So evolution might have either restricted the depth of vision or it might have given us enhanced brains to handle so much information.

 Another problem of such a vision is the resolution and detail you can see. You might see blobs of colors but can you make out finer details ? No !! . The reason being heat transfer. Heat moves from objects of higher temperature to lower temperature. so any given time all objects will be trying to get closer to the temperature of the objects they are in touch. Thus heat transfer will define the borders between objects. But the details.might be lost. The resolution or detail you can see would be very minimal. Humans have developed such awesome IR camera these days that makes it possible to see so much detail. We may have evolved to see such detail with infrared but we can't really say with certainty. 


 May be that is why we evolved the way we did. We are just right the way we are . There is nothing that can change. We are perfectly alright the way we are. Blessed , may be. And hope humans don't mess it up. 

God , if he exists, would have been a crazy mathematician. He would point out and say , do you see the probability of your existence and the way you are. Our presence on earth is a miracle of a million possibilities. To say that it just happened and was not according to some grand plan, is something that would be hard to explain. God is one of the answers to such a question.

Saturday, March 10, 2012

Thread Name Based Logging for Log4J

In a multi-threaded environment , it sometimes becomes hard to debug parts of the application because you constantly have logs from multiple threads. Simplest method to debug such cases is to do a grep on the thread name .  I have been asked a few times if it was possible to log messages happening in one thread to a separate file.  I couldn't find such a implementation. Log4J , which is what i have mostly been using , didnt have anything of that kind out there .

The drawback with Log4j configuration is that , you have to assign appenders to packages . So if you wanted to log a particular functionality in a separate file, you have to design your code packages in such a way that all classes related to that functionality  share the same package ( or package hierarchy ) . This is fine and that is how you would usually structure your code. But the problem arises when you use third party libraries . These end up not being captured along with your file , so it becomes useless once you separate a package to use a different log file . 


The only way we could capture the entire flow is  by using the Thread names. ( like we would do with a grep ). So log messages from each thread can be routed to seperate files. Not many would prefer this , i doubt anybody would want to do this . But if you are using a naming convention for threads then it would be easier to do the routing.In my case , we are doing that in my current project. So here is my attempt to do just that with a custom appender for Log4j. 

 ThreadNamePatternAppender is an appender for routing your Logging messages to multiple files by using the thread name patterns as a key . 
E.g You have 2 threads that have the names(Thread.getName())
       Consumer and Producer. 
 You can route the logging from the Consumer Thread to Cosumer.log and logging from Producer Thread to Producer.log with a log4j.properties that  looks as follows


log4j.rootLogger=DEBUG, MY_THREAD_APPENDER

log4j.appender.MY_THREAD_APPENDER=com.rex.logging.appender.ThreadNamePatternAppender
log4j.appender.MY_THREAD_APPENDER.defaultFile=EveryThingElse.log
log4j.appender.MY_THREAD_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.MY_THREAD_APPENDER.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n
log4j.appender.MY_THREAD_APPENDER.threadNameMapping=Consumer>Consumer.log|Producer>Producer.log

  
 This uses a DailyRollingFileAppender internally. So you should be able to use all the parameters   you would use with a DailyRollingFileAppender like DatePattern , Encoding etc. So you can control how frequently the files needs to be rolled over. However you cant control it at each thread level , but you can control it at an appender level.

 If you have multiple threads sharing the Same name or Have similar names , They can be routed to the same file by using * along with the names. 
  
   e.g If there are Threads by the name Consumer-1 , Consumer-2 , Consumer-3 ,     you can route messages from all three threads to the same file as follows .

 log4j.appender.MY_THREAD_APPENDER.threadNameMapping=Consumer*>Consumer.log|Producer>Producer.log


You can add multiple Thread name mappings by separating them with a pipe '|'.


You can download the jar for this from here .  You can view the code here 




Tuesday, January 03, 2012

End of Days


       Happy new year,  2012 is here.


                       An eventful year just got over. Another starts . This year is predicted to be the year of doom . Why? Well the Mayans were too bored to go beyond this year on their calendar.  Dec 21st , 2012  is marked for apocalypse and Armageddon. End of the World ( EOW , better this way cause I don’t like the sound of it). So is it true ? Is the world really going to end ? Should I be preparing a bucket list ? Well , I don’t know if I should care about the Mayan calendar getting over or what Nostradamus scribbled when he was drunk. Never the less , there has been a huge set of people who strongly believe that the EOW is a possibility. Many are damn right sure about it being an assured phenomenon.  


                      There is not much base to this prediction. How will the EOW happen ? Earthquake ? Asteroid ? Wrath of the Titans?  21/12 being a palindrome , I find it too filmy a number to believe in it. But what if it really does happen ? What do we do ?  


                       The best we can do is to be prepared. 21/12 might have been predicted , but there are events that are bound to happen due to the unpredictable nature of nature . And here are few things that can help you during / after such a crisis . Of course this is only if it isn't a total wipe out.  




1)  Get a stock of some essentials and have them ready at home at all times. 

      • First Aid kit , Medicines  
      • A Water filter  and a Stock of fresh water for 2 weeks .  
      • Food for at least 2 weeks, non perishable food , Dry Fruits. 
      • Some basic tools , A Swiss knife . 
      • Batteries . ( not a pair,  a whole lot of them ). 
      • A Torch / Flashlight. 
      • A good ole Radio  ( FM / AM ) and a Walkie-Talkie . 
      • Matches / Lighter. 
      • An Alternative SIM from an adjoining state ( To avoid network Jam during crisis ) .  

2) When a disaster occurs, I don’t think Google will be able to answer your questions. So once in a while practice thinking "What would my grandparents do to get this done?"   


3) Keep a copy of your important documents at some other location, Say a relative staying in another city.


4) Staying Calm and collected during the crisis will save your ass for the most part.  


5) Save yourselves. Then think about others . I know there is nothing heroic about this but the fact is people helping others are the ones that get killed. ( I salute them , but cant do that in person ). Post catastrophe, Check yourself for injuries and then start helping others .  


6) Get Educated on what to do in various situations.


Now to the specifics . 


1) Earthquakes / Tsunami / Cyclones  

  • These are serious and ever present dangers .  Worst part is they are by products of most EOW scenarios .  
  • Please read through the survival info publish on the following sites ( Google / Bing for more )  

2) Asteroid Crash 

  • This is scary and very much possible  
  • NEO ( Near Earth Objects ) can disrupt surface activity or erupt to create havoc .  
  • All previous occurrences have  known to cause terrible damage ( one of which particularly made sure I can never ride on the back of  Sauropod to school )  
  • Only solution I can think of, is an Armageddon style rescue .  

3) Solar Flare  

  • A Strong enough solar flare can have  the same effect as an atomic bomb, Just a little way bit more powerful than that . Extreme heat , Radiation .
  • If it is a smaller flare , that leaves us alive . First thing you will notice is that your fancy smart phone and your TV don’t work . because a solar flare will have a EMP ( Electro Magnetic Pulse ) accompanying it . So , that will put us at "What would my Great Great Grand father do ?" ideology. 
  • Radiation post flare will still last for a long time. So we would end up living in Tin Foil Tents  . 

4) Crazy Planet alignment causes cosmic energies to affect everything on earth. 

  • Consult a gemologist . Get a bunch of rings .  
  • Wear your lucky charm 
  • On a serious note , These can cause Tsunamis and Earthquakes. 

5) Kali yuga 

  • This is the EOW as predicted in the Hindu texts.  
  •  Be good , do Good , Think Good to survive Kalki's wrath. 
  • Bible's Armageddon . Nostradamus predictions . All the same 

6) Zombie Apocalypse .  

  • Get Fit , you are going to be doing a lot of running  
  • Stay away from tunnels and closed paths. After watching so many movies , you will know that is where most people die ( and horrible background scores are created ) .  
  • Don’t be a hero and go around investigating surroundings. There will be a zombie behind door no 2.   
  • Get Guns :D . All those years of playing first person shooters , this will be your true test.   

7) Meddling Scientists 

  • This is my best bet for a cause for the EOW . I am guessing some crazy scientist will be poking at the dynamics of energies / particles he does not understand and unintentionally create Armegeddon. 
  • Current researches are on God particle and Antimatter. These are things that could cause a black hole and gobble the planet as a whole . 
  • Silliest but plausible reason for an EOW. 

8 ) Alien Invasion 

  •  Learn a language , you never know what they will speak .
  • Learn to play the piano . ( Close Encounters ) 
  • Have a vial of Common Cold virus handy , it will come to be of use. ( War of the worlds ) 



              Other possibilities of concern are Nuclear war , Global Warming and Chuck Norris's Sneeze . No matter what , I am sure we will survive. Earth survived a million years , we will survive a million more. Live today like there is no tomorrow


BTW , Don't forget to create your bucket list :P