How to make the headers of two fits files the same in IDL? - idl-programming-language

I have to make the header of a fits file called 'exponential.fits' the same as the header of 'empirical.fits'. Is there any way to do it with writefits.pro?

Yes, you can do this with writefits.pro but you will end up overwriting the file that already exists so you may want to look into doing it with another program. But the way to do it using writefits (assuming you wanted the 0th extension header) would be:
; get the header you want and the data of the file you need
empirical_hdr = headfits('empirical.fits') ;header
exponential_data = readfits('exponential.fits') ;data
;overwrite the exponential.fits with what you want
writefits,'exponential.fits',exponential_data,header=empirical_hdr

Related

How to get rid of the original file path instead of name in PGP encryption with ChoPGP library?

I tried PGP encrypting a file in ChoPGP library. At the end of the process it shows embedded file name along with the whole original file name path.
But I thought it will show only the filename without the whole path. Which I intend to work on and figure out a way to do so?
Doing the following:
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
pgp.EncryptFile(#"\\appdevtest\c$\appstest\Transporter\test\Test.txt",
#"\\appdevtest\c$\appstest\Transporter\test\OSCTestFile_ChoPGP.gpg",
#"\\appdevtest\c$\appstest\Transporter\pgpKey\PublicKey\atorres\atorres_publicKey.asc",
true,
true);
}
which will result in:
But I would like to only extract the Test.txt in the end something
like this:
Looking at this line from the ChoPGP sources: https://github.com/Cinchoo/ChoPGP/blob/7152c7385022823013324408e84cb7e25d33c3e7/ChoPGP/ChoPGPEncryptDecrypt.cs#L221
You may find out that it uses internal function GetFileName, which ends up with this for the FileStream: return ((FileStream)stream).Name;.
And this one, according to documentation, Gets the absolute path of the file opened in the FileStream..
So you should either make fork of ChoPGP and modify this line to extract just filename, or submit a pull request to the ChoPGP. Btw, it's just a wrapper around the BouncyCastle so you may use that instead.

Is there any way to use read.fortran() to read a string rather than file?

So my problem is the following, I am reading through a text file using readlines, and have to go line by line until there is a trigger, and then I have to read the following line using read.fortran().
The problem is that read.fortran() only read text files, and I need to read a line (a string). At the moment I have solved this problem with a disastrous function which writes a file and then I read the file.
read.fortran.string <- function(x_string, x_format, x_file, col.names){
# Disastrous function to be changed
if (missing(x_file)){
x_file = r'(C:\Users\your_user\Documents\tempfolder\line.txt)'
}
write(x_string,x_file)
df = read.fortran(x_file, x_format)
if (!missing(col.names)){
colnames(df) <-col.names
}
return(df)
}
I was expecting that someone will point to a different solution in which:
Do not require to hardcode a path
Do not require having to have writing permission
I believe that
read.fortran(textConnection(x_string), x_format)
will do what you want (untested!)

Yocto: Is there a way to remove items of SRC_URI in local.conf?

We are using custom kernel, so I override variables defined in linux-imx_xxx.bb:
KERNEL_SRC_pn-linux-imx = "our_url"
SRCBRANCH_pn-linux-imx = "our_branch"
SRCREV_pn-linux-imx = "${AUTOREV}"
It works. But many patch files added in linux-imx_xxx.bb and out custom kernel have patched.
So I want to just remove patch files in local.conf, and not touch any .bb files defined in official meta-fsl-* layers.
SRC_URI_remove_pn-linux-imx = " file://*.patch"
But this doesn't work. So is there a way to do this in local.conf?
BTW I know the .bbappend should works, but again, I don't want change any meta-fsl-* layers.
You can't use a wildcard because _remove is literal string removal. Spell out the files you want to remove, and you'll be fine.
However if you're using a custom kernel then just write a new recipe for it, no point taking linux-imx and editing it from local.conf.

Get the real extension of a file vb.net

I would like to determine real file extension.
example :
file = "test.fakeExt"
// but the real extention is .exe // for security reason I wish to avoid using it!
How can I do that?
If you want to determine the extension you could use findmimefromdata.
It looks at the first part of the file to determine what type of file it is.
FindMimeFromData function
Sample code
The first two bytes of an .exe file are allways 'MZ'.
So you could read the binary file, and see if the first two bytes are MZ, then you know it's an .exe file...

$ sign after each line in files(UNIX OS)

I am new to vim editor and based on general reading from different forums, I was trying to customize vim by updating the .vimrc file to look something like this:
syntax on
set incsearch
set ignorecase
set smartcase
set wildmode = list
that gives me a whole set of functionality I need. However, after having saved this content to .vimrc, suddenly all my files started to show $ as the ending character after each line.
i.e. Now even the .vimrc file looks like:
syntax on$
set incsearch$
set ignorecase$
set smartcase$
set wildmode = list$
and unfortunately I am not able to delete them in the editor. Are there any comments on how to get rid of these '$' signs? Has anyone else encountered this problem before?
Thanks in advance!
The line set wildmode = list is wrong, it should be set wildmode=list no spaces.
The line as it is queries the wildmode option and sets the boolean list option
It’s because you said set list.
Go check for init.vim file.
For me that file was at /home/user/.config/nvim/init.vim
And it was turn on "See invisible characters":
set list listchars=tab:>\ ,trial:+,eol:&
Delete or comment the line.

Resources