Installing and reading grib files on google colab - cfgrib

Pretty simple queston..
I need to open data using cfgrib in xarray. I have it working perfectly fine on spyder but I have to do this in google colab.
url = 'https://nomads.ncep.noaa.gov/cgi-bin/filter_hrrr_2d.pl?file=hrrr.t{run}z.wrfsfcf{fhr1}.grib2&lev_surface=on&var_PRATE=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=%2Fhrrr.{ymd}%2Fconus'
URL = url.format(run=run, fhr1=fhr1, ymd=ymd)
r = requests.get(URL)
with open(r"C:\Users\kevin\Documents\extradata\hrr.hail.03", 'wb') as fh:
fh.write(r.content)
ds12 = xr.open_dataset(r"C:\Users\kevin\Documents\extradata\hrr.hail.03", engine='cfgrib')
It says its not an option to use the engine='cfgrib' . I have had this problem before on spyder but I found with pip install cfgrib fixed it but on google colab it still does not work..

Related

Is there any way to import an external file in Google Colab?

Hello I would like to import an txt file from a GitHub. Is there any way to import this file in Google Colab?
I don't want to download the file and import this one because when I will open the Google Colab again it won't be
I found a way in case it helps someone:
url = 'https://...'
r = requests.get(url, allow_redirects=True)
open('data.txt', 'wb').write(r.content)

How does !npx degit work in Google Colab?

I'm trying to read files from my Github repository in Google Colab. I found this answer that instructed me to use:
!npx degit Jainu-s/urldata/al -f
Which copies the files from my repository as local Colab files. It works perfectly, but I have no ideia what this code does exactly and I could not find any Colab documentation on it.
Can anyone explain to me how it works? What is its syntax, what does it do? And what are the options I could use with it?
You can read its documentation.
https://github.com/Rich-Harris/degit
Basically,
the program is degit
npx is to execute without install it
/al means you download that directory content
f is force download, because the directory is not empty
To read more
!npx degit --help

Can the drive API be used to upload notebooks for use in colaboratory?

The examples in External data: Drive, Sheets, and Cloud Storage show how to work with plain drive files, authenticated with the assistance of google.colab. Could I use something similar to post my notebooks from non-colaboratory over to colaboratory?
Sure, it's possible to use the Drive Python API to upload Colab notebooks. (The google.colab auth module is a convenience wrapper to obtain OAuth credentials.)
But, Colab and Jupyter share the same JSON file format. So, the easiest thing to do is to just upload the files to Drive directly, e.g., using the web UI or the desktop sync client.
You can also upload a notebook by selecting 'Upload notebook' in the File menu of the Colab web app.
Here's an example notebook I created in Jupyter which uploads itself to Drive using gcloud and standard Drive APIs. (The libraries needed are pip-installed in the notebook if you don't have them.)

Protractor Running exe with child_process

i'm trying to simulate an upload file with protractor
i know that the protractor can't interact with OS window
and i created an EXE file (with autoit), that takes focus and insert a file .
when i'm testing manually everything working ok .
when i try to write it in protractor i get error
this is my protractor code ( using child_process ) -- see pic
Here is my error massage
tried using : NO LUCK!!
You don't need AutoIT to upload files. Just send full absolute path to file that you want to upload into upload input. If you are running tests with Selenium Grid you also need to use FileDetector to send file to node where test is running:
var FileDetector = require('selenium-webdriver/remote/index.js').FileDetector;
browser.setFileDetector(new FileDetector());
var path = require('path');
var fileToUpload = '../yourfile.txt',
absolutePath = path.resolve(__dirname, fileToUpload);
$('hiddenfileuploadinput').sendKeys(absolutePath)
Here is question that has answers that might help:
How to upload file in angularjs e2e protractor testing
I have faced the same error while working on mine. I had to open a .exe file using protractor. Putting the right path to .exe worked for me. Can you also re-check if it's the right path

Upload new ipython notebook to wakari

I am not sure if this question is too specific to Wakari, but I figured I would give it a shot since there are a number of Wakari related posts on stackoverflow now. The question was this. Does anyone know how to upload an ipython notebook from your desktop pc to Wakari? I have a notebook that I have developed on my pc and I want to share it through Wakari. Do I have to manually copy all of the stuff from the notebook to the Wakari ipython notebook, or can I just upload the notebook file . . . ? Any suggestions would be appreciated.
Perhaps this is just for data files (not notebooks), but you can upload files according to this:
https://www.wakari.io/docs/data.html#upload
If your local copy is in a git repo, it would be easy to push it to github and then access it from there:
https://www.wakari.io/docs/accessing.html