Thursday, February 12, 2015

HDF5 get mode and header


##########################################################
#example:
#
#$ getmode U.V1 31,31,15
#
#      (31,31,15): {
#            0.000210922,
#            -0.000870292
#         }
##########################################################
function getmode {
    h5dump -d /$1 -s "$2" -S "1,1,1" -c "1,1,1" -k "1,1,1" $1.h5 | sed -n '14,17p'
}
#########################################################
#example:
#
#$ getheader U.V1
#
#HDF5 "U.V1.h5" {
#GROUP "/" {
#   DATASET "U.V1" {
#      DATATYPE  H5T_COMPOUND {
#         H5T_IEEE_F32LE "real";
#         H5T_IEEE_F32LE "imag";
#      }
#      DATASPACE  SIMPLE { ( 32, 32, 17 ) / ( 32, 32, 17 ) }
#   }
#}
#}
##########################################################
function getheader {
    h5dump --header $1.h5
}

#Reference:
http://davis.lbl.gov/Manuals/HDF5-1.4.3/Tutor/util.html
http://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file 

Wednesday, February 11, 2015

Execute python in an external terminal in sublime

Open $HOME/.config/sublime-text-2/Packages/User/Python.sublime-build
and write.
{
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "working_dir": "${file_path}",
    "selector": "source.python",

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["gnome-terminal", "-x", "bash", "-c", "python '$file'; echo -e \"\n\nPress any key to exit\"; read"],
            "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
            "working_dir": "${file_path}",
            "selector": "source.python"
        }
    ]
}
you may either use the second line for using internal build terminal or the first line for external terminal.