Tuesday, June 28, 2016

Create Clickable imagesc for 2D data

Looking at the figure is fun, specially if you can click and get the values. So, created this little function which can give you title and data tips @cursor location.
function imagesca(x, titlewant)
h = figure;
imagesc(x);
colorbar
try
    title(titlewant);
catch ME
    title('Figure')
end
datacursormode on

Thursday, June 16, 2016

Print a large poster on multiple A4/paper


There are two ways:
1. Save the (powerpoint) document as  pdf.
2. Open the pdf, print.
3. Select the appropriate options in the poster option in the page size and handling section
4. The options are Tile scale: 200% for example, overlap by few tenth of the inches
5. Cutmarks and labels etc are optional #4 does the magic!

Another way that I learned from the internet is to paste the picture in the excel sheet. The excel is smart enough to segment the pic into multiple pages. And, I used to think that extra flowing line being printed into second page was a bad feature in excel! :)

Wednesday, June 15, 2016

Dropbox over server

Well, I had some failures in the past. So, I wanted to try again.
First, I had to run headless install via command line.
Then ran the Dropbox daemon from the newly created .dropbox-dist folder.
~/.dropbox-dist/dropboxd
That got me a unique link to link dropbox account to cloud.
Then I got the dropbox.py code from the help page (https://www.dropbox.com/install?os=lnx)
Rest was not bad!
Here are some of the commands that I had to run... because I wanted to exclude bunch of folders from syncing. I wish there was "include" option instead of "exclude".

~/bin/dropbox.py exclude add ~/Dropbox/MyExclude1 ~/Dropbox/MyExclude2 

~/bin/dropbox.py exclude list 

~/bin/dropbox.py help ~/bin/dropbox.py status ~/bin/dropbox.py start

Plot LST

Just a code to plot LST
Lat  = double(hdfread(filewant,  'Latitude' ));
Lon  =  double(hdfread(filewant,  'Longitude' ));
LST = 0.02* double(hdfread(filewant,  'LST' ));
LST(LST==0)=NaN;
figure

load coast
latlim=[floor(min(min(Lat))),ceil(max(max(Lat))) ]; lonlim=[floor(min(min(Lon))),ceil(max(max(Lon))) ];
ax = worldmap(latlim, lonlim);
surfacem(Lat, Lon, LST);
geoshow(lat, long,'Color', 'black' )
colormap; set(gcf,'Color','white')
map2 = colormap; map2( 1, : ) = 0; colormap(map2);
colorbar % saveas(gcf, 'plotHDF.png', 'png') close all
caxis([ 290 330])

Tuesday, June 14, 2016

Chrome: Add keyboard shortcut to your favorite website


This trick works on Google chrome. 
  • Right click on the address bar
  • Edit Search Engines
  • Scroll to the bottom of the list
  • Give the name, keyword (eg. gs: for google scholar), then URL.
You can put %s in place of query.



Monday, June 13, 2016

Matlab Colorbar: LST

I think I found a good one! (Sorry intensity, no one prints grayscale pics these days... they just read on-screen).
r1 = [1 0];
g1 = [0 0];
b1 =  [1 1];
rgb1 = [r1; g1; b1]';
rgba = interp1([1 2],rgb1, linspace(1,2,16 ));
r1 = [0 0];
g1 = [0 1];
b1 =  [1 1];
rgb1 = [r1; g1; b1]';
rgbb = interp1([1 2],rgb1, linspace(1,2,11 ));

r1 = [0 0];
g1 = [1 1];
b1 =  [1 0];
rgb1 = [r1; g1; b1]';
rgbc = interp1([1 2],rgb1, linspace(1,2,10));

r1 = [0 1];
g1 = [1 1];
b1 =  [0 0];
rgb1 = [r1; g1; b1]';
rgbd = interp1([1 2],rgb1, linspace(1,2,11 ));

r1 = [ 1 1];
g1 = [1 0];
b1 =  [0 0];
rgb2 = [r1; g1; b1]';
rgbe= interp1([1 2],rgb2, linspace(1,2,16));

newNDVI = [rgba;rgbb;rgbc;rgbd;rgbe];

newNDVI= interp1( newNDVI, linspace(1,64,256));


%
figure
plot([1:256],newNDVI(:,1), 'ro-'); hold on
plot([1:256],newNDVI(:,2), 'g*-');
plot([1:256],newNDVI(:,3), 'bd-.');
xlim([1 256])

colormap(newNDVI );
cmap = colormap; % cmap nicely puts colormap into 3 col data
% colorbar
caxis([0 1])
hc = colorbar('southoutside');
set(hc, 'FontSize', 16)

 axis off; set(gcf,'Color','White')


I can append white and or black at the end for distinction, if needed.

Wednesday, June 1, 2016

Insert the date and time into the google docs

This first appeared here ... http://ajabgajab.blogspot.com/2015/01/insert-date-and-time-into-google-docs.html 
This is how you insert the date and time to the google docs

1. Go to the Google document/new document.
2. Go to the Tools/Script Editor, and insert the following script at the bottom of the scripts.
This will create a new menu. You can modify the code to change the appearance of the month/date.
3. See the end note to add automated date entry!

The code is available below/ at pastebin.
http://pastebin.com/QFpTRQ3h




function onOpen() {
  var ui = DocumentApp.getUi();
  // Or FormApp or SpreadsheetApp.
  ui.createMenu('Insert Date')
      .addItem('Insert Date', 'insertDate')
      .addToUi();

}

function insertDate() {
  var cursor = DocumentApp.getActiveDocument().getCursor();
  if (cursor) {
      // Attempt to insert text at the cursor position. If insertion returns null,
      // then the cursor's containing element doesn't allow text insertions.
      var d = new Date();
      var dd = d.getDate();
      var hrs = d.getHours();
      var min = d.getMinutes();
      dd = pad(dd, 2)
      var mm = d.getMonth() + 1; //Months are zero based
      mm = pad(mm, 2)
      var yyyy = d.getFullYear();
    var date =  "Date: "+mm + "-" +dd + "-" + yyyy+ "::"+hrs+":"+min +"\n";
      var element = cursor.insertText(date);
      if (element) {
        element.setBold(true);
      } else {
        DocumentApp.getUi().alert('Cannot insert text at this cursor location.');
      }
    } else {
      DocumentApp.getUi().alert('Cannot find a cursor in the document.');
  }

}
function pad (str, max) {
  str = str.toString();
  return str.length < max ? pad("0" + str, max) : str;
}

--- 
--> 

Note:
If you add the following function call inside the onOpen() function:
  insertDate();
Then you will get automated insertion of date and time. Great for logging the daily notes!!!




function onOpen() {
  var ui = DocumentApp.getUi();
  // Or FormApp or SpreadsheetApp.
  ui.createMenu('Insert Date')
      .addItem('Insert Date', 'insertDate')
      .addToUi();

  insertDate();

}