_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q26800 | DirectoryPinger.ping_entry | train | def ping_entry(self, entry):
"""
Ping an entry to a directory.
"""
entry_url = '%s%s' % (self.ressources.site_url,
entry.get_absolute_url())
categories = '|'.join([c.title for c in entry.categories.all()])
try:
reply = self.serve... | python | {
"resource": ""
} |
q26801 | ExternalUrlsPinger.run | train | def run(self):
"""
Ping external URLs in a Thread.
"""
logger = getLogger('zinnia.ping.external_urls')
socket.setdefaulttimeout(self.timeout)
external_urls = self.find_external_urls(self.entry)
external_urls_pingable = self.find_pingback_urls(external_urls)
... | python | {
"resource": ""
} |
q26802 | ExternalUrlsPinger.is_external_url | train | def is_external_url(self, url, site_url):
"""
Check if the URL is an external URL.
"""
url_splitted = urlsplit(url)
| python | {
"resource": ""
} |
q26803 | ExternalUrlsPinger.find_external_urls | train | def find_external_urls(self, entry):
"""
Find external URLs in an entry.
"""
soup = BeautifulSoup(entry.html_content, 'html.parser')
external_urls = [a['href'] for a in soup.find_all('a')
| python | {
"resource": ""
} |
q26804 | ExternalUrlsPinger.find_pingback_href | train | def find_pingback_href(self, content):
"""
Try to find LINK markups to pingback URL.
"""
soup = BeautifulSoup(content, 'html.parser')
for link in soup.find_all('link'):
dict_attr = dict(link.attrs)
if 'rel' in dict_attr and 'href' in dict_attr: | python | {
"resource": ""
} |
q26805 | ExternalUrlsPinger.find_pingback_urls | train | def find_pingback_urls(self, urls):
"""
Find the pingback URL for each URLs.
"""
pingback_urls = {}
for url in urls:
try:
page = urlopen(url)
headers = page.info()
server_url = headers.get('X-Pingback')
... | python | {
"resource": ""
} |
q26806 | ExternalUrlsPinger.pingback_url | train | def pingback_url(self, server_name, target_url):
"""
Do a pingback call for the target URL.
"""
try:
server = ServerProxy(server_name)
reply = server.pingback.ping(self.entry_url, | python | {
"resource": ""
} |
q26807 | get_categories | train | def get_categories(context, template='zinnia/tags/categories.html'):
"""
Return the published categories.
"""
return {'template': template, | python | {
"resource": ""
} |
q26808 | get_categories_tree | train | def get_categories_tree(context, template='zinnia/tags/categories_tree.html'):
"""
Return the categories as a tree.
"""
return {'template': template,
| python | {
"resource": ""
} |
q26809 | get_authors | train | def get_authors(context, template='zinnia/tags/authors.html'):
"""
Return the published authors.
"""
return {'template': template,
| python | {
"resource": ""
} |
q26810 | get_featured_entries | train | def get_featured_entries(number=5,
template='zinnia/tags/entries_featured.html'):
"""
Return the featured entries.
""" | python | {
"resource": ""
} |
q26811 | get_draft_entries | train | def get_draft_entries(number=5,
template='zinnia/tags/entries_draft.html'):
"""
Return the last draft entries.
"""
| python | {
"resource": ""
} |
q26812 | get_popular_entries | train | def get_popular_entries(number=5, template='zinnia/tags/entries_popular.html'):
"""
Return popular entries.
"""
return | python | {
"resource": ""
} |
q26813 | get_similar_entries | train | def get_similar_entries(context, number=5,
template='zinnia/tags/entries_similar.html'):
"""
Return similar entries.
"""
entry = context.get('entry')
if not entry:
return {'template': | python | {
"resource": ""
} |
q26814 | get_calendar_entries | train | def get_calendar_entries(context, year=None, month=None,
template='zinnia/tags/entries_calendar.html'):
"""
Return an HTML calendar of entries.
"""
if not (year and month):
day_week_month = (context.get('day') or
context.get('week') or
... | python | {
"resource": ""
} |
q26815 | get_recent_comments | train | def get_recent_comments(number=5, template='zinnia/tags/comments_recent.html'):
"""
Return the most recent comments.
"""
# Using map(smart_text... fix bug related to issue #8554
entry_published_pks = map(smart_text,
Entry.published.values_list('id', flat=True))
| python | {
"resource": ""
} |
q26816 | get_recent_linkbacks | train | def get_recent_linkbacks(number=5,
template='zinnia/tags/linkbacks_recent.html'):
"""
Return the most recent linkbacks.
"""
entry_published_pks = map(smart_text,
Entry.published.values_list('id', flat=True))
content_type = ContentType.objects.ge... | python | {
"resource": ""
} |
q26817 | zinnia_pagination | train | def zinnia_pagination(context, page, begin_pages=1, end_pages=1,
before_pages=2, after_pages=2,
template='zinnia/tags/pagination.html'):
"""
Return a Digg-like pagination,
by splitting long list of page into 3 blocks of pages.
"""
get_string = ''
for k... | python | {
"resource": ""
} |
q26818 | zinnia_breadcrumbs | train | def zinnia_breadcrumbs(context, root_name='',
template='zinnia/tags/breadcrumbs.html',):
"""
Return a breadcrumb for the application.
"""
path = context['request'].path
context_object = get_context_first_object(
context, ['object', 'category', 'tag', 'author'])
| python | {
"resource": ""
} |
q26819 | zinnia_loop_template | train | def zinnia_loop_template(context, default_template):
"""
Return a selected template from his position within a loop
and the filtering context.
"""
matching, context_object = get_context_first_matching_object(
context,
['category', 'tag', 'author', 'pattern',
'year', 'month',... | python | {
"resource": ""
} |
q26820 | get_gravatar | train | def get_gravatar(email, size=80, rating='g', default=None,
protocol=PROTOCOL):
"""
Return url for a Gravatar.
"""
gravatar_protocols = {'http': 'http://www',
'https': 'https://secure'}
url = '%s.gravatar.com/avatar/%s' % (
| python | {
"resource": ""
} |
q26821 | get_tag_cloud | train | def get_tag_cloud(context, steps=6, min_count=None,
template='zinnia/tags/tag_cloud.html'):
"""
Return a cloud of published tags.
"""
tags = Tag.objects.usage_for_queryset(
Entry.published.all(), counts=True,
| python | {
"resource": ""
} |
q26822 | comment_admin_urlname | train | def comment_admin_urlname(action):
"""
Return the admin URLs for the comment app used.
"""
comment = get_comment_model()
return 'admin:%s_%s_%s' % (
| python | {
"resource": ""
} |
q26823 | user_admin_urlname | train | def user_admin_urlname(action):
"""
Return the admin URLs for the user app used.
"""
user = get_user_model()
return 'admin:%s_%s_%s' % ( | python | {
"resource": ""
} |
q26824 | zinnia_statistics | train | def zinnia_statistics(template='zinnia/tags/statistics.html'):
"""
Return statistics on the content of Zinnia.
"""
content_type = ContentType.objects.get_for_model(Entry)
discussions = get_comment_model().objects.filter(
content_type=content_type)
entries = Entry.published
categorie... | python | {
"resource": ""
} |
q26825 | EntryCacheMixin.get_object | train | def get_object(self, queryset=None):
"""
Implement cache on ``get_object`` method to
avoid repetitive calls, in POST.
"""
if self._cached_object is None:
self._cached_object | python | {
"resource": ""
} |
q26826 | PasswordMixin.password | train | def password(self):
"""
Return the password view.
"""
return self.response_class(request=self.request,
| python | {
"resource": ""
} |
q26827 | ping_directories_handler | train | def ping_directories_handler(sender, **kwargs):
"""
Ping directories when an entry is saved.
"""
entry = kwargs['instance']
if entry.is_visible and settings.SAVE_PING_DIRECTORIES:
| python | {
"resource": ""
} |
q26828 | ping_external_urls_handler | train | def ping_external_urls_handler(sender, **kwargs):
"""
Ping externals URLS when an entry is saved.
"""
entry = kwargs['instance']
| python | {
"resource": ""
} |
q26829 | count_discussions_handler | train | def count_discussions_handler(sender, **kwargs):
"""
Update the count of each type of discussion on an entry.
"""
if kwargs.get('instance') and kwargs.get('created'):
# The signal is emitted by the comment creation,
# so we do nothing, comment_was_posted is used instead.
return
... | python | {
"resource": ""
} |
q26830 | count_pingbacks_handler | train | def count_pingbacks_handler(sender, **kwargs):
"""
Update Entry.pingback_count when a pingback was posted.
"""
entry = kwargs['entry']
| python | {
"resource": ""
} |
q26831 | count_trackbacks_handler | train | def count_trackbacks_handler(sender, **kwargs):
"""
Update Entry.trackback_count when a trackback was posted.
"""
entry = kwargs['entry']
| python | {
"resource": ""
} |
q26832 | connect_entry_signals | train | def connect_entry_signals():
"""
Connect all the signals on Entry model.
"""
post_save.connect(
ping_directories_handler, sender=Entry,
dispatch_uid=ENTRY_PS_PING_DIRECTORIES)
post_save.connect(
| python | {
"resource": ""
} |
q26833 | disconnect_entry_signals | train | def disconnect_entry_signals():
"""
Disconnect all the signals on Entry model.
"""
post_save.disconnect(
sender=Entry,
dispatch_uid=ENTRY_PS_PING_DIRECTORIES)
post_save.disconnect(
sender=Entry,
dispatch_uid=ENTRY_PS_PING_EXTERNAL_URLS)
post_save.disconnect(
... | python | {
"resource": ""
} |
q26834 | connect_discussion_signals | train | def connect_discussion_signals():
"""
Connect all the signals on the Comment model to
maintains a valid discussion count on each entries
when an action is done with the comments.
"""
post_save.connect(
count_discussions_handler, sender=comment_model,
dispatch_uid=COMMENT_PS_COUNT... | python | {
"resource": ""
} |
q26835 | disconnect_discussion_signals | train | def disconnect_discussion_signals():
"""
Disconnect all the signals on Comment model
provided by Zinnia.
"""
post_save.disconnect(
sender=comment_model,
dispatch_uid=COMMENT_PS_COUNT_DISCUSSIONS)
post_delete.disconnect(
sender=comment_model,
dispatch_uid=COMMENT_P... | python | {
"resource": ""
} |
q26836 | QuickEntry.dispatch | train | def dispatch(self, *args, **kwargs):
"""
Decorate the view dispatcher with permission_required.
"""
| python | {
"resource": ""
} |
q26837 | QuickEntry.post | train | def post(self, request, *args, **kwargs):
"""
Handle the datas for posting a quick entry,
and redirect to the admin in case of error or
to the entry's page in case of success.
"""
now = timezone.now()
data = {
'title': request.POST.get('title'),
... | python | {
"resource": ""
} |
q26838 | EntryCommentModerator.moderate | train | def moderate(self, comment, entry, request):
"""
Determine if a new comment should be marked as non-public
and await approval.
Return ``True`` to put the comment into the moderator queue,
or ``False`` to allow it to be showed up immediately.
"""
| python | {
"resource": ""
} |
q26839 | EntryCommentModerator.email | train | def email(self, comment, entry, request):
"""
Send email notifications needed.
"""
current_language = get_language()
try:
activate(settings.LANGUAGE_CODE)
site = Site.objects.get_current()
if self.auto_moderate_comments or comment.is_public:
... | python | {
"resource": ""
} |
q26840 | EntryCommentModerator.do_email_notification | train | def do_email_notification(self, comment, entry, site):
"""
Send email notification of a new comment to site staff.
"""
if not self.mail_comment_notification_recipients:
return
template = loader.get_template(
'comments/zinnia/entry/email/notification.txt')... | python | {
"resource": ""
} |
q26841 | EntryCommentModerator.do_email_authors | train | def do_email_authors(self, comment, entry, site):
"""
Send email notification of a new comment to
the authors of the entry.
"""
if not self.email_authors:
return
exclude_list = self.mail_comment_notification_recipients + ['']
recipient_list = (
... | python | {
"resource": ""
} |
q26842 | EntryCommentModerator.do_email_reply | train | def do_email_reply(self, comment, entry, site):
"""
Send email notification of a new comment to
the authors of the previous comments.
"""
if not self.email_reply:
return
exclude_list = (
self.mail_comment_notification_recipients
+ [aut... | python | {
"resource": ""
} |
q26843 | EntryWeek.get_dated_items | train | def get_dated_items(self):
"""
Override get_dated_items to add a useful 'week_end_day'
variable in the extra context of the view.
"""
self.date_list, self.object_list, extra_context = super(
EntryWeek, self).get_dated_items()
self.date_list = self.get_date_lis... | python | {
"resource": ""
} |
q26844 | Calendar.formatday | train | def formatday(self, day, weekday):
"""
Return a day as a table cell with a link
if entries are published this day.
"""
if day and day in self.day_entries:
day_date = date(self.current_year, self.current_month, day)
archive_day_url = reverse('zinnia:entry_a... | python | {
"resource": ""
} |
q26845 | Calendar.formatfooter | train | def formatfooter(self, previous_month, next_month):
"""
Return a footer for a previous and next month.
"""
footer = '<tfoot><tr>' \
'<td colspan="3" class="prev">%s</td>' \
'<td class="pad"> </td>' \
'<td colspan="3" class="next">%s... | python | {
"resource": ""
} |
q26846 | Calendar.formatmonthname | train | def formatmonthname(self, theyear, themonth, withyear=True):
"""Return a month name translated as | python | {
"resource": ""
} |
q26847 | append_position | train | def append_position(path, position, separator=''):
"""
Concatenate a path and a position,
between the | python | {
"resource": ""
} |
q26848 | loop_template_list | train | def loop_template_list(loop_positions, instance, instance_type,
default_template, registry):
"""
Build a list of templates from a position within a loop
and a registry of templates.
"""
templates = []
local_loop_position = loop_positions[1]
global_loop_position = loop_... | python | {
"resource": ""
} |
q26849 | get_url_shortener | train | def get_url_shortener():
"""
Return the selected URL shortener backend.
"""
try:
backend_module = import_module(URL_SHORTENER_BACKEND)
backend = getattr(backend_module, 'backend')
except (ImportError, AttributeError):
warnings.warn('%s backend cannot be imported' % URL_SHORTE... | python | {
"resource": ""
} |
q26850 | generate_pingback_content | train | def generate_pingback_content(soup, target, max_length, trunc_char='...'):
"""
Generate a description text for the pingback.
"""
link = soup.find('a', href=target)
content = strip_tags(six.text_type(link.findParent()))
index = content.index(link.string)
if len(content) > max_length:
... | python | {
"resource": ""
} |
q26851 | EntryTrackback.dispatch | train | def dispatch(self, *args, **kwargs):
"""
Decorate the view dispatcher with csrf_exempt.
"""
| python | {
"resource": ""
} |
q26852 | EntryTrackback.get | train | def get(self, request, *args, **kwargs):
"""
GET only do a permanent redirection to the Entry.
"""
| python | {
"resource": ""
} |
q26853 | EntryTrackback.post | train | def post(self, request, *args, **kwargs):
"""
Check if an URL is provided and if trackbacks
are enabled on the Entry.
If so the URL is registered one time as a trackback.
"""
url = request.POST.get('url')
if not url:
return self.get(request, *args, **... | python | {
"resource": ""
} |
q26854 | Sitemap.get_context_data | train | def get_context_data(self, **kwargs):
"""
Populate the context of the template
with all published entries and all the categories.
"""
context = super(Sitemap, self).get_context_data(**kwargs)
context.update(
| python | {
"resource": ""
} |
q26855 | get_spam_checker | train | def get_spam_checker(backend_path):
"""
Return the selected spam checker backend.
"""
try:
backend_module = import_module(backend_path)
backend = getattr(backend_module, 'backend')
except (ImportError, AttributeError):
warnings.warn('%s backend cannot be imported' % backend_p... | python | {
"resource": ""
} |
q26856 | check_is_spam | train | def check_is_spam(content, content_object, request,
backends=None):
"""
Return True if the content is a spam, else False.
"""
if backends is None:
backends = SPAM_CHECKER_BACKENDS | python | {
"resource": ""
} |
q26857 | PreviousNextPublishedMixin.get_previous_next_published | train | def get_previous_next_published(self, date):
"""
Returns a dict of the next and previous date periods
with published entries.
"""
previous_next = getattr(self, 'previous_next', None)
if previous_next is None:
date_year = datetime(date.year, 1, 1)
... | python | {
"resource": ""
} |
q26858 | BaseEntrySearch.get_queryset | train | def get_queryset(self):
"""
Overridde the get_queryset method to
do some validations and build the search queryset.
"""
entries = Entry.published.none()
if self.request.GET:
self.pattern = self.request.GET.get('pattern', '')
if len(self.pattern) <... | python | {
"resource": ""
} |
q26859 | BaseEntrySearch.get_context_data | train | def get_context_data(self, **kwargs):
"""
Add error and pattern in context.
"""
| python | {
"resource": ""
} |
q26860 | BaseAuthorDetail.get_queryset | train | def get_queryset(self):
"""
Retrieve the author by his username and
build a queryset of his published entries.
| python | {
"resource": ""
} |
q26861 | BaseAuthorDetail.get_context_data | train | def get_context_data(self, **kwargs):
"""
Add the current author in context.
| python | {
"resource": ""
} |
q26862 | BaseTagDetail.get_queryset | train | def get_queryset(self):
"""
Retrieve the tag by his name and
build a queryset of his published entries.
"""
self.tag = get_tag(self.kwargs['tag'])
if self.tag is None:
raise Http404(_('No Tag found matching "%s".') %
| python | {
"resource": ""
} |
q26863 | BaseTagDetail.get_context_data | train | def get_context_data(self, **kwargs):
"""
Add the current tag in context.
| python | {
"resource": ""
} |
q26864 | read_analogy_file | train | def read_analogy_file(filename):
"""
Read the analogy task test set from a file.
"""
section = None
with open(filename, 'r') as questions_file:
for line in questions_file:
if line.startswith(':'):
| python | {
"resource": ""
} |
q26865 | analogy_rank_score | train | def analogy_rank_score(analogies, word_vectors, no_threads=1):
"""
Calculate the analogy rank score for the given set of analogies.
A rank of zero denotes a perfect score; with random word vectors
we would expect a rank of 0.5.
Arguments:
- analogies: a numpy array holding the ids of the words... | python | {
"resource": ""
} |
q26866 | Corpus.fit | train | def fit(self, corpus, window=10, ignore_missing=False):
"""
Perform a pass through the corpus to construct
the cooccurrence matrix.
Parameters:
- iterable of lists of strings corpus
- int window: the length of the (symmetric)
context window used for cooccurrenc... | python | {
"resource": ""
} |
q26867 | Glove.fit | train | def fit(self, matrix, epochs=5, no_threads=2, verbose=False):
"""
Estimate the word embeddings.
Parameters:
- scipy.sparse.coo_matrix matrix: coocurrence matrix
- int epochs: number of training epochs
- int no_threads: number of training threads
- bool verbose: p... | python | {
"resource": ""
} |
q26868 | Glove.add_dictionary | train | def add_dictionary(self, dictionary):
"""
Supply a word-id dictionary to allow similarity queries.
"""
if self.word_vectors is None:
raise Exception('Model must be fit before adding a dictionary')
if len(dictionary) > self.word_vectors.shape[0]:
raise Ex... | python | {
"resource": ""
} |
q26869 | Glove.save | train | def save(self, filename):
"""
Serialize model to filename.
"""
with open(filename, 'wb') as savefile:
pickle.dump(self.__dict__,
| python | {
"resource": ""
} |
q26870 | Glove.load | train | def load(cls, filename):
"""
Load model from filename.
"""
instance = Glove()
with open(filename, 'rb') as savefile:
| python | {
"resource": ""
} |
q26871 | Glove.most_similar | train | def most_similar(self, word, number=5):
"""
Run a similarity query, retrieving number
most similar words.
"""
if self.word_vectors is None:
raise Exception('Model must be fit before querying')
if self.dictionary is None:
raise Exception('No word ... | python | {
"resource": ""
} |
q26872 | set_gcc | train | def set_gcc():
"""
Try to find and use GCC on OSX for OpenMP support.
"""
# For macports and homebrew
patterns = ['/opt/local/bin/gcc-mp-[0-9].[0-9]',
'/opt/local/bin/gcc-mp-[0-9]',
'/usr/local/bin/gcc-[0-9].[0-9]',
'/usr/local/bin/gcc-[0-9]']
if... | python | {
"resource": ""
} |
q26873 | RandomizedSearchCV.fit | train | def fit(self, X, y=None, groups=None):
"""Run fit on the estimator with randomly drawn parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples in the number of samples and
n_features is the number of fea... | python | {
"resource": ""
} |
q26874 | _new_java_obj | train | def _new_java_obj(sc, java_class, *args):
"""
Construct a new Java object.
"""
java_obj = _jvm()
for name in java_class.split("."):
java_obj = | python | {
"resource": ""
} |
q26875 | _call_java | train | def _call_java(sc, java_obj, name, *args):
"""
Method copied from pyspark.ml.wrapper. Uses private Spark APIs.
"""
m = getattr(java_obj, name)
| python | {
"resource": ""
} |
q26876 | SAFEMSIMDXML.get_area_def | train | def get_area_def(self, dsid):
"""Get the area definition of the dataset."""
geocoding = self.root.find('.//Tile_Geocoding')
epsg = geocoding.find('HORIZONTAL_CS_CODE').text
rows = int(geocoding.find('Size[@resolution="' + str(dsid.resolution) + '"]/NROWS').text)
cols = int(geocod... | python | {
"resource": ""
} |
q26877 | SAFEMSIMDXML._get_coarse_dataset | train | def _get_coarse_dataset(self, key, info):
"""Get the coarse dataset refered to by `key` from the XML data."""
angles = self.root.find('.//Tile_Angles')
if key in ['solar_zenith_angle', 'solar_azimuth_angle']:
elts = angles.findall(info['xml_tag'] + '/Values_List/VALUES')
... | python | {
"resource": ""
} |
q26878 | SAFEMSIMDXML.get_dataset | train | def get_dataset(self, key, info):
"""Get the dataset refered to by `key`."""
angles = self._get_coarse_dataset(key, info)
if angles is None:
return
# Fill gaps at edges of swath
darr = DataArray(angles, dims=['y', 'x'])
darr = darr.bfill('x')
darr = ... | python | {
"resource": ""
} |
q26879 | AMSR2L1BFileHandler.get_shape | train | def get_shape(self, ds_id, ds_info):
"""Get output shape of specified dataset."""
var_path = ds_info['file_key']
shape = self[var_path + | python | {
"resource": ""
} |
q26880 | AMSR2L1BFileHandler.get_dataset | train | def get_dataset(self, ds_id, ds_info):
"""Get output data and metadata of specified dataset."""
var_path = ds_info['file_key']
fill_value = ds_info.get('fill_value', 65535)
metadata = self.get_metadata(ds_id, ds_info)
data = self[var_path]
if ((ds_info.get('standard_name... | python | {
"resource": ""
} |
q26881 | find_coefficient_index | train | def find_coefficient_index(sensor, wavelength_range, resolution=0):
"""Return index in to coefficient arrays for this band's wavelength.
This function search through the `COEFF_INDEX_MAP` dictionary and
finds the first key where the nominal wavelength of `wavelength_range`
falls between the minimum wav... | python | {
"resource": ""
} |
q26882 | run_crefl | train | def run_crefl(refl, coeffs,
lon,
lat,
sensor_azimuth,
sensor_zenith,
solar_azimuth,
solar_zenith,
avg_elevation=None,
percent=False,
use_abi=False):
"""Run main crefl algorithm.
All inp... | python | {
"resource": ""
} |
q26883 | make_day_night_masks | train | def make_day_night_masks(solarZenithAngle,
good_mask,
highAngleCutoff,
lowAngleCutoff,
stepsDegrees=None):
"""
given information on the solarZenithAngle for each point,
generate masks defining where the day, ... | python | {
"resource": ""
} |
q26884 | _histogram_equalization_helper | train | def _histogram_equalization_helper(valid_data, number_of_bins, clip_limit=None, slope_limit=None):
"""Calculate the simplest possible histogram equalization, using only valid data.
Returns:
cumulative distribution function and bin information
"""
# bucket all the selected data using np's hist... | python | {
"resource": ""
} |
q26885 | _calculate_weights | train | def _calculate_weights(tile_size):
"""
calculate a weight array that will be used to quickly bilinearly-interpolate the histogram equalizations
tile size should be the width and height of a tile in pixels
returns a 4D weight array, where the first 2 dimensions correspond to the grid of where the tiles ... | python | {
"resource": ""
} |
q26886 | _linear_normalization_from_0to1 | train | def _linear_normalization_from_0to1(
data,
mask,
theoretical_max,
theoretical_min=0,
message="normalizing equalized data to fit in 0 to 1 range"):
"""Do a linear normalization so all data is in the 0 to 1 range.
This is a sloppy but fast calculation that relies on parame... | python | {
"resource": ""
} |
q26887 | HistogramDNB._run_dnb_normalization | train | def _run_dnb_normalization(self, dnb_data, sza_data):
"""Scale the DNB data using a histogram equalization method.
Args:
dnb_data (ndarray): Day/Night Band data array
sza_data (ndarray): Solar Zenith Angle data array
"""
# convert dask arrays to DataArray object... | python | {
"resource": ""
} |
q26888 | AdaptiveDNB._run_dnb_normalization | train | def _run_dnb_normalization(self, dnb_data, sza_data):
"""Scale the DNB data using a adaptive histogram equalization method.
Args:
dnb_data (ndarray): Day/Night Band data array
sza_data (ndarray): Solar Zenith Angle data array
"""
# convert dask arrays to DataArr... | python | {
"resource": ""
} |
q26889 | CLAVRXFileHandler._read_pug_fixed_grid | train | def _read_pug_fixed_grid(projection, distance_multiplier=1.0):
"""Read from recent PUG format, where axes are in meters
"""
a = projection.semi_major_axis
h = projection.perspective_point_height
b = projection.semi_minor_axis
lon_0 = projection.longitude_of_projection_or... | python | {
"resource": ""
} |
q26890 | CLAVRXFileHandler._read_axi_fixed_grid | train | def _read_axi_fixed_grid(self, l1b_attr):
"""CLAVR-x does not transcribe fixed grid parameters to its output
We have to recover that information from the original input file,
which is partially named as L1B attribute
example attributes found in L2 CLAVR-x files:
sensor = "AHI" ;... | python | {
"resource": ""
} |
q26891 | Plugin.load_yaml_config | train | def load_yaml_config(self, conf):
"""Load a YAML configuration file and recursively update the overall configuration."""
with open(conf) as fd:
| python | {
"resource": ""
} |
q26892 | VIIRSCompactFileHandler.read_geo | train | def read_geo(self, key, info):
"""Read angles.
"""
pairs = {('satellite_azimuth_angle', 'satellite_zenith_angle'):
("SatelliteAzimuthAngle", "SatelliteZenithAngle"),
('solar_azimuth_angle', 'solar_zenith_angle'):
("SolarAzimuthAngle", "SolarZeni... | python | {
"resource": ""
} |
q26893 | get_cds_time | train | def get_cds_time(days, msecs):
"""Get the datetime object of the time since epoch given in days and
milliseconds | python | {
"resource": ""
} |
q26894 | dec10216 | train | def dec10216(inbuf):
"""Decode 10 bits data into 16 bits words.
::
/*
* pack 4 10-bit words in 5 bytes into 4 16-bit words
*
* 0 1 2 3 4 5
* 01234567890123456789012345678901234567890
* 0 1 2 3 4
... | python | {
"resource": ""
} |
q26895 | chebyshev | train | def chebyshev(coefs, time, domain):
"""Evaluate a Chebyshev Polynomial
Args:
coefs (list, np.array): Coefficients defining the polynomial
time (int, float): Time where to evaluate | python | {
"resource": ""
} |
q26896 | SEVIRICalibrationHandler._erads2bt | train | def _erads2bt(self, data, channel_name):
"""Computation based on effective radiance."""
cal_info = CALIB[self.platform_id][channel_name]
| python | {
"resource": ""
} |
q26897 | SEVIRICalibrationHandler._ir_calibrate | train | def _ir_calibrate(self, data, channel_name, cal_type):
"""Calibrate to brightness temperature."""
if cal_type == 1:
# spectral radiances
return self._srads2bt(data, channel_name)
elif cal_type == 2:
| python | {
"resource": ""
} |
q26898 | SEVIRICalibrationHandler._srads2bt | train | def _srads2bt(self, data, channel_name):
"""Computation based on spectral radiance."""
a__, b__, c__ = BTFIT[channel_name]
wavenumber = CALIB[self.platform_id][channel_name]["VC"]
| python | {
"resource": ""
} |
q26899 | SEVIRICalibrationHandler._tl15 | train | def _tl15(self, data, wavenumber):
"""Compute the L15 temperature."""
return ((C2 * wavenumber) /
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.